isledef

package
v0.0.0-...-0eba227 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2018 License: GPL-3.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FntGoRegular    string = "goregular"
	FntGoBold              = "gobold"
	FntGoItalic            = "goitalic"
	FntGoMono              = "gomono"
	FntGoBoldItalic        = "gobolditalic"
	FntKorean              = "korean"
	FntKoreanBold          = "koreanbold"
	FntEmoji               = "notoemoji"
	FntSymbols             = "notosymbols"
	FntSmallPixel          = "smallpixel"
)

All possible fonts

View Source
const (
	TileEmpty int = iota
	TileOccupied
	TileEmptyShot
	TileOccupiedShot
)

Represent the different tiles on the grid

View Source
const (
	ShipTypeBattleShip ShipType = "Bake-Kujira"
	ShipTypeCruiser             = "Kraken"
	ShipTypePatrol              = "Umibozu"
	ShipTypeSubmarine           = "Mishipeshu"
)

All the available ship types

Variables

View Source
var (
	//ZoomLevel is the overall zoom of the game for ease of use
	ZoomLevel        float64
	SpalooshSheet    *SpriteSheet
	PlaySoundEffects = true
	AIBroke          = false
	TimeRanOut       = false
)
View Source
var GameServer *network.GameServer

Functions

func ChoosePosition

func ChoosePosition(col, row, length int, g *Grid) (bool, bool)

ChoosePosition determines if the ship can fit in the spot given, including turning the ship vertically. Otherwise returns false

func HandleConnection

func HandleConnection(p *Player, g *Game)

func PauseBGM

func PauseBGM() error

func PlayBGM

func PlayBGM(bgm BGM) error

func PlaySE

func PlaySE(se string) error

func PlayerChoosePosition

func PlayerChoosePosition(col, row, length int, vertical bool, g *Grid) bool

PlayerChoosePosition determines if the ship can fit in the spot given with the given orientation

func ResumeBGM

func ResumeBGM(bgm BGM) error

func SetBGMVolume

func SetBGMVolume(volume float64)

Types

type AI

type AI struct {
	Name  string
	Level int
	// contains filtered or unexported fields
}

AI represents the computer controlled opponent

func NewAI

func NewAI() *AI

func (*AI) NetworkSetMyBoard

func (ai *AI) NetworkSetMyBoard(g *Grid) []*network.PlaceShipType

SetBoard is called at the beginning of the game so the AI sets its pieces on the game board

func (*AI) NetworkSetOpponentBoard

func (ai *AI) NetworkSetOpponentBoard(g *Grid, shipPlacements []*network.PlaceShipType)

SetBoard is called at the beginning of the game so the AI sets its pieces on the game board

func (*AI) ResetBoard

func (ai *AI) ResetBoard(g *Grid)

ResetBoard removes the current ships and resets them for the given grid

func (*AI) SetBoard

func (ai *AI) SetBoard(g *Grid)

SetBoard is called at the beginning of the game so the AI sets its pieces on the game board

func (*AI) TakeShot

func (ai *AI) TakeShot(grid *Grid) bool

TakeShot has the AI take a shot at the battleship style grid Returns true if there was a successful shot taken (hit or miss)

type BGM

type BGM string
const (
	BGM0 BGM = "FindYouMarch.ogg"
	BGM1 BGM = "high seas.ogg"
)

type BattleCharSelect

type BattleCharSelect struct {
	// contains filtered or unexported fields
}

func CreateBattleCharSelect

func CreateBattleCharSelect(g *Game) *BattleCharSelect

func (*BattleCharSelect) Draw

func (t *BattleCharSelect) Draw(game *Game) error

func (*BattleCharSelect) Msg

func (t *BattleCharSelect) Msg() GameStateMsg

func (*BattleCharSelect) SetMsg

func (t *BattleCharSelect) SetMsg(msg GameStateMsg)

func (*BattleCharSelect) Update

func (t *BattleCharSelect) Update(game *Game) error

type BulletCounter

type BulletCounter struct {
	*tentsuyu.BasicObject
	// contains filtered or unexported fields
}

func NewBulletCounter

func NewBulletCounter(x, y float64, gd *GameData) *BulletCounter

func (*BulletCounter) Draw

func (bc *BulletCounter) Draw(screen *ebiten.Image) error

func (*BulletCounter) Fire

func (bc *BulletCounter) Fire()

type Character

type Character struct {
	*tentsuyu.BasicObject

	Name string
	// contains filtered or unexported fields
}

Character represents the player characters

func NewCharacter

func NewCharacter(name string) *Character

func (*Character) Draw

func (c *Character) Draw(screen *ebiten.Image) error

Draw the character

func (*Character) DrawBust

func (c *Character) DrawBust(screen *ebiten.Image) error

DrawBust the character

func (*Character) DrawBustSad

func (c *Character) DrawBustSad(screen *ebiten.Image) error

DrawBustSad the character

func (*Character) SetScale

func (c *Character) SetScale(scale float64)

type EnemyDisplay

type EnemyDisplay struct {
	// contains filtered or unexported fields
}

func NewEnemyDisplay

func NewEnemyDisplay(x, y float64, smallGrid bool) *EnemyDisplay

func (*EnemyDisplay) Draw

func (ed *EnemyDisplay) Draw(screen *ebiten.Image) error

func (*EnemyDisplay) Update

func (ed *EnemyDisplay) Update(ships []*Ship)

type Frame

type Frame struct {
	Filename         string             `json:"filename"`
	Frame            map[string]int     `json:"frame"`
	Rotated          bool               `json:"rotated"`
	Trimmed          bool               `json:"trimmed"`
	SpriteSourceSize map[string]int     `json:"spriteSourceSize"`
	SourceSize       map[string]int     `json:"sourceSize"`
	Pivot            map[string]float64 `json:"pivot"`
}

Frame represents a single frame of a spritesheet

type Game

type Game struct {
	// contains filtered or unexported fields
}

Game represents the game itself

func NewGame

func NewGame(w, h int) (game *Game, err error)

NewGame begins a new game of spaloosh!

func (*Game) DrawBackground

func (g *Game) DrawBackground() error

func (*Game) Loop

func (g *Game) Loop(screen *ebiten.Image) error

Loop controls everything that goes on in the game

func (*Game) ToggleFullscreen

func (g *Game) ToggleFullscreen()

ToggleFullscreen toggles the game in or out of full screen

func (*Game) ToggleSound

func (g *Game) ToggleSound()

type GameBattle

type GameBattle struct {
	ZoomLevel float64
	// contains filtered or unexported fields
}

GameBattle is the main game...

func NewGameBattle

func NewGameBattle(g *Game) *GameBattle

NewGameBattle creates a GameBattle state

func (*GameBattle) Draw

func (gm *GameBattle) Draw(g *Game) error

Draw the main game

func (*GameBattle) Msg

func (gm *GameBattle) Msg() GameStateMsg

Msg returns the current state's message

func (*GameBattle) SetMsg

func (gm *GameBattle) SetMsg(msg GameStateMsg)

SetMsg sets the GameStateMsg

func (*GameBattle) Update

func (gm *GameBattle) Update(g *Game) error

Update the main game

type GameData

type GameData struct {
	// contains filtered or unexported fields
}

GameData contains data for the game

func NewGameData

func NewGameData(gameMode GameMode) *GameData

NewGameData creates a new GameData to keep track of the game

func (*GameData) SetGameMode

func (g *GameData) SetGameMode(gameMode GameMode)

SetGameMode sets the game mode chosen by the character. In this case used for Timed mode to set number of bombs

func (*GameData) TimeInMilliseconds

func (g *GameData) TimeInMilliseconds() int64

TimeInMilliseconds returns the current time in seconds

func (*GameData) TimeInSecond

func (g *GameData) TimeInSecond() int

TimeInSecond returns the current time in seconds

func (*GameData) Update

func (g *GameData) Update()

Update the game time

type GameMain

type GameMain struct {
	ZoomLevel float64
	// contains filtered or unexported fields
}

GameMain is the main game...

func NewGameMain

func NewGameMain(g *Game) *GameMain

NewGameMain creates a GameMain state

func (*GameMain) Draw

func (gm *GameMain) Draw(g *Game) error

Draw the main game

func (*GameMain) Msg

func (gm *GameMain) Msg() GameStateMsg

Msg returns the current state's message

func (*GameMain) SetMsg

func (gm *GameMain) SetMsg(msg GameStateMsg)

SetMsg sets the game state message

func (*GameMain) Update

func (gm *GameMain) Update(g *Game) error

Update the main game

type GameMode

type GameMode int

GameMode represents the difficulty/mode of the game

const (
	GameModeNormalTimed GameMode = iota
	GameModeHardcoreTimed
	GameModeNormalBattle
	GameModeOnlineHost
	GameModeOnlineJoin
	GameModeOnlineRoom
)

Currently available game modes

type GameOver

type GameOver struct {
	// contains filtered or unexported fields
}

GameOver is displayed when the game is over

func CreateGameOver

func CreateGameOver(g *Game, win bool) *GameOver

CreateGameOver creates either a winning screen or losing screen depending on the bool value

func (*GameOver) Draw

func (t *GameOver) Draw(game *Game) error

Draw GameOver scene

func (*GameOver) Msg

func (t *GameOver) Msg() GameStateMsg

Msg returns the gamestate msg

func (*GameOver) SetMsg

func (t *GameOver) SetMsg(msg GameStateMsg)

func (*GameOver) Update

func (t *GameOver) Update(game *Game) error

Update GameOver screen

type GameState

type GameState interface {
	Update(g *Game) error
	Draw(g *Game) error
	Msg() GameStateMsg
	SetMsg(GameStateMsg)
}

GameState represents the current state of the game

type GameStateMsg

type GameStateMsg int

GameStateMsg represents the messages sent from the GameState that may change states

const (
	GameStateMsgNone GameStateMsg = iota
	GameStateMsgReqTitle
	GameStateMsgReqMain
	GameStateGameOver
	GameStateGameWin
	GameStateMsgReqMainMenu
	GameStateMsgReqBattle
	GameStateMsgPause
	GameStateMsgUnPause
	GameStateMsgReqMPStage
	GameStateMsgReqMPMain
	GameStateMsgReqMPMainMenu
	GameStateMsgReqLostConnection
	GameStateMsgReqBattleCharacterSelect
	GameStateMsgReqMPHelp
	GameStateMsgReqMPGameOverWin
	GameStateMsgReqMPGameOverLose
	GameStateMsgReqHostingRooms
	GameStateMsgReqSetIP
)

These are the available GameStateMsg

type Grid

type Grid struct {
	*tentsuyu.BasicObject

	Rows    int
	Columns int

	Ships []*Ship

	Cleared bool
	// contains filtered or unexported fields
}

Grid represents the game playing field

func CreateGrid

func CreateGrid(x, y float64, rows, cols int) *Grid

CreateGrid returns a Grid which represents the game field

func (*Grid) AIShot

func (g *Grid) AIShot(row, col int) (bool, bool, bool)

AIShot takes a row and col and returns 3 values: ShotMiss, ShotHit, ShipSunk

func (Grid) DetermineTile

func (g Grid) DetermineTile(x, y float64) (int, int, int)

DetermineTile returns the value at the grid This is used to use the mouse coords

func (*Grid) Draw

func (g *Grid) Draw(screen *ebiten.Image) error

Draw the Grid

func (*Grid) ExportNetworkPlacements

func (g *Grid) ExportNetworkPlacements() []*network.PlaceShipType

func (*Grid) MPSpecial

func (g *Grid) MPSpecial(game *Game) (bool, int, int)

Update the grid

func (*Grid) MPUpdate

func (g *Grid) MPUpdate(game *Game) (bool, int, int)

Update the grid

func (*Grid) MakeAllVisible

func (g *Grid) MakeAllVisible()

MakeAllVisible is used at the end of a round to see any ships you may have missed

func (*Grid) PlaceShip

func (g *Grid) PlaceShip(row, col int, shipType ShipType, vertical bool)

PlaceShip puts the ship at the right place in the grid

func (Grid) PrintGrid

func (g Grid) PrintGrid()

PrintGrid prints the text representation of the game grid

func (*Grid) RemoveShip

func (g *Grid) RemoveShip(ship *Ship)

func (Grid) ReturnXYCoords

func (g Grid) ReturnXYCoords(row, col int) (float64, float64)

ReturnXYCoords returns the float values for the given row and col

func (*Grid) SpecialAttack

func (g *Grid) SpecialAttack(game *Game) bool

SpecialAttack is unique to each game character

func (*Grid) Update

func (g *Grid) Update(game *Game) bool

Update the grid

func (*Grid) UpdatePlacement

func (g *Grid) UpdatePlacement(game *Game)

type Icon

type Icon struct {
	X, Y float64
	// contains filtered or unexported fields
}

type LostConnection

type LostConnection struct {
	// contains filtered or unexported fields
}

LostConnection is displayed when the game is over

func CreateLostConnection

func CreateLostConnection() *LostConnection

CreateLostConnection creates either a winning screen or losing screen depending on the bool value

func (*LostConnection) Draw

func (t *LostConnection) Draw(game *Game) error

Draw LostConnection scene

func (*LostConnection) Msg

func (t *LostConnection) Msg() GameStateMsg

Msg returns the gamestate msg

func (*LostConnection) SetMsg

func (t *LostConnection) SetMsg(msg GameStateMsg)

func (*LostConnection) Update

func (t *LostConnection) Update(game *Game) error

Update LostConnection screen

type MPBattle

type MPBattle struct {
	ZoomLevel float64
	// contains filtered or unexported fields
}

MPBattle is the main game...

func NewMPBattle

func NewMPBattle(g *Game) *MPBattle

NewMPBattle creates a MPBattle state

func (*MPBattle) Draw

func (gm *MPBattle) Draw(g *Game) error

Draw the main game

func (*MPBattle) Msg

func (gm *MPBattle) Msg() GameStateMsg

Msg returns the current state's message

func (*MPBattle) SendHello

func (gm *MPBattle) SendHello(p *Player, now time.Time)

func (*MPBattle) SendMessage

func (gm *MPBattle) SendMessage(p *Player, row, col int)

func (*MPBattle) SendShipPlacements

func (gm *MPBattle) SendShipPlacements(p *Player, shipPlacements []*network.PlaceShipType)

func (*MPBattle) SetMsg

func (gm *MPBattle) SetMsg(msg GameStateMsg)

SetMsg sets the GameStateMsg

func (*MPBattle) Update

func (gm *MPBattle) Update(g *Game) error

Update the main game

type MPGameOver

type MPGameOver struct {
	// contains filtered or unexported fields
}

MPGameOver is displayed when the game is over

func CreateMPGameOver

func CreateMPGameOver(g *Game, win bool) *MPGameOver

CreateMPGameOver creates either a winning screen or losing screen depending on the bool value

func (*MPGameOver) Draw

func (t *MPGameOver) Draw(game *Game) error

Draw MPGameOver scene

func (*MPGameOver) LostConnection

func (t *MPGameOver) LostConnection()

func (*MPGameOver) Msg

func (t *MPGameOver) Msg() GameStateMsg

Msg returns the gamestate msg

func (*MPGameOver) SetMsg

func (t *MPGameOver) SetMsg(msg GameStateMsg)

func (*MPGameOver) Update

func (t *MPGameOver) Update(game *Game) error

Update MPGameOver screen

type MPHelp

type MPHelp struct {
	// contains filtered or unexported fields
}

func CreateMPHelp

func CreateMPHelp(g *Game) *MPHelp

func (*MPHelp) Draw

func (t *MPHelp) Draw(game *Game) error

func (*MPHelp) Msg

func (t *MPHelp) Msg() GameStateMsg

func (*MPHelp) SetMsg

func (t *MPHelp) SetMsg(msg GameStateMsg)

func (*MPHelp) Update

func (t *MPHelp) Update(game *Game) error

type MPMainMenu

type MPMainMenu struct {
	// contains filtered or unexported fields
}

func CreateMPMainMenu

func CreateMPMainMenu(g *Game) *MPMainMenu

func (*MPMainMenu) Draw

func (t *MPMainMenu) Draw(game *Game) error

func (*MPMainMenu) Msg

func (t *MPMainMenu) Msg() GameStateMsg

func (*MPMainMenu) SetMsg

func (t *MPMainMenu) SetMsg(msg GameStateMsg)

func (*MPMainMenu) Update

func (t *MPMainMenu) Update(game *Game) error

type MPRooms

type MPRooms struct {
	// contains filtered or unexported fields
}

func CreateMPRooms

func CreateMPRooms(g *Game) *MPRooms

func (*MPRooms) AddRooms

func (t *MPRooms) AddRooms(rooms []int, p *Player)

AddRooms returns all the available rooms from the server and number of people in each one

func (*MPRooms) Draw

func (t *MPRooms) Draw(game *Game) error

func (*MPRooms) Msg

func (t *MPRooms) Msg() GameStateMsg

func (*MPRooms) SetMsg

func (t *MPRooms) SetMsg(msg GameStateMsg)

func (*MPRooms) Update

func (t *MPRooms) Update(game *Game) error

type MPSetIP

type MPSetIP struct {
	// contains filtered or unexported fields
}

func CreateMPSetIP

func CreateMPSetIP(g *Game) *MPSetIP

func (*MPSetIP) Draw

func (t *MPSetIP) Draw(game *Game) error

func (*MPSetIP) Msg

func (t *MPSetIP) Msg() GameStateMsg

func (*MPSetIP) SetMsg

func (t *MPSetIP) SetMsg(msg GameStateMsg)

func (*MPSetIP) Update

func (t *MPSetIP) Update(game *Game) error

type MPStage

type MPStage struct {
	// contains filtered or unexported fields
}

func CreateMPStage

func CreateMPStage(g *Game) *MPStage

func (*MPStage) Draw

func (t *MPStage) Draw(game *Game) error

func (*MPStage) Msg

func (t *MPStage) Msg() GameStateMsg

func (*MPStage) SetMsg

func (t *MPStage) SetMsg(msg GameStateMsg)

func (*MPStage) Update

func (t *MPStage) Update(game *Game) error
type MainMenu struct {
	// contains filtered or unexported fields
}

func CreateMainMenu

func CreateMainMenu(g *Game) *MainMenu
func (t *MainMenu) Draw(game *Game) error
func (t *MainMenu) Msg() GameStateMsg
func (t *MainMenu) SetMsg(msg GameStateMsg)
func (t *MainMenu) Update(game *Game) error

type Paused

type Paused struct {
	// contains filtered or unexported fields
}

Paused is displayed when the game is over

func CreatePaused

func CreatePaused() *Paused

CreatePaused creates either a winning screen or losing screen depending on the bool value

func (*Paused) Draw

func (t *Paused) Draw(game *Game) error

Draw Paused scene

func (*Paused) Msg

func (t *Paused) Msg() GameStateMsg

Msg returns the gamestate msg

func (*Paused) SetMsg

func (t *Paused) SetMsg(msg GameStateMsg)

func (*Paused) Update

func (t *Paused) Update(game *Game) error

Update Paused screen

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player represents the player

func CreatePlayer

func CreatePlayer(g *Game) *Player

CreatePlayer returns a pointer to a Player

func (*Player) Reset

func (p *Player) Reset()

func (*Player) TakeShot

func (p *Player) TakeShot() bool

TakeShot takes a shot and returns true if the player can take a shot. Otherwise return false

func (*Player) Update

func (p *Player) Update()

Update the player

type SE

type SE string

type Ship

type Ship struct {
	*tentsuyu.BasicObject
	// contains filtered or unexported fields
}

Ship represents the ships on the board (in other words the game pieces)

func CreateShip

func CreateShip(x, y float64, shipType ShipType, vertical bool) *Ship

CreateShip at point (x,y) or type shipType

func (*Ship) Draw

func (s *Ship) Draw(screen *ebiten.Image) error

Draw the ship

func (*Ship) Hit

func (s *Ship) Hit(x, y int)

Hit is called when the ship is hit with a correct shot

func (*Ship) ReturnHitCount

func (s *Ship) ReturnHitCount() int

ReturnHitCount returns the number of hits the ship can take before sinking

func (*Ship) Update

func (s *Ship) Update()

Update the ship while it is being moved about the board

type ShipType

type ShipType string

ShipType represents the different ship types

type SoundPlayer

type SoundPlayer struct {
	// contains filtered or unexported fields
}

type SpriteSheet

type SpriteSheet struct {
	Frames []*Frame `json:"frames"`
}

SpriteSheet holds all frames of a spritesheet from a json

func ReadSpriteSheet

func ReadSpriteSheet(filename string) *SpriteSheet

ReadSpriteSheet reads a json file and returns a SpriteSheet struct

func ReadSpriteSheetJSON

func ReadSpriteSheetJSON(jsonByte []byte) *SpriteSheet

type TitleMain

type TitleMain struct {
	// contains filtered or unexported fields
}

func CreateTitleMain

func CreateTitleMain() *TitleMain

func (*TitleMain) Draw

func (t *TitleMain) Draw(game *Game) error

func (*TitleMain) Msg

func (t *TitleMain) Msg() GameStateMsg

func (*TitleMain) SetMsg

func (t *TitleMain) SetMsg(msg GameStateMsg)

func (*TitleMain) Update

func (t *TitleMain) Update(game *Game) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL