Documentation ¶
Index ¶
- Constants
- Variables
- func ChoosePosition(col, row, length int, g *Grid) (bool, bool)
- func HandleConnection(p *Player, g *Game)
- func PauseBGM() error
- func PlayBGM(bgm BGM) error
- func PlaySE(se string) error
- func PlayerChoosePosition(col, row, length int, vertical bool, g *Grid) bool
- func ResumeBGM(bgm BGM) error
- func SetBGMVolume(volume float64)
- type AI
- type BGM
- type BattleCharSelect
- type BulletCounter
- type Character
- type EnemyDisplay
- type Frame
- type Game
- type GameBattle
- type GameData
- type GameMain
- type GameMode
- type GameOver
- type GameState
- type GameStateMsg
- type Grid
- func (g *Grid) AIShot(row, col int) (bool, bool, bool)
- func (g Grid) DetermineTile(x, y float64) (int, int, int)
- func (g *Grid) Draw(screen *ebiten.Image) error
- func (g *Grid) ExportNetworkPlacements() []*network.PlaceShipType
- func (g *Grid) MPSpecial(game *Game) (bool, int, int)
- func (g *Grid) MPUpdate(game *Game) (bool, int, int)
- func (g *Grid) MakeAllVisible()
- func (g *Grid) PlaceShip(row, col int, shipType ShipType, vertical bool)
- func (g Grid) PrintGrid()
- func (g *Grid) RemoveShip(ship *Ship)
- func (g Grid) ReturnXYCoords(row, col int) (float64, float64)
- func (g *Grid) SpecialAttack(game *Game) bool
- func (g *Grid) Update(game *Game) bool
- func (g *Grid) UpdatePlacement(game *Game)
- type Icon
- type LostConnection
- type MPBattle
- func (gm *MPBattle) Draw(g *Game) error
- func (gm *MPBattle) Msg() GameStateMsg
- func (gm *MPBattle) SendHello(p *Player, now time.Time)
- func (gm *MPBattle) SendMessage(p *Player, row, col int)
- func (gm *MPBattle) SendShipPlacements(p *Player, shipPlacements []*network.PlaceShipType)
- func (gm *MPBattle) SetMsg(msg GameStateMsg)
- func (gm *MPBattle) Update(g *Game) error
- type MPGameOver
- type MPHelp
- type MPMainMenu
- type MPRooms
- type MPSetIP
- type MPStage
- type MainMenu
- type Paused
- type Player
- type SE
- type Ship
- type ShipType
- type SoundPlayer
- type SpriteSheet
- type TitleMain
Constants ¶
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
const ( TileEmpty int = iota TileOccupied TileEmptyShot TileOccupiedShot )
Represent the different tiles on the grid
const ( ShipTypeBattleShip ShipType = "Bake-Kujira" ShipTypeCruiser = "Kraken" ShipTypePatrol = "Umibozu" ShipTypeSubmarine = "Mishipeshu" )
All the available ship types
Variables ¶
var ( //ZoomLevel is the overall zoom of the game for ease of use ZoomLevel float64 SpalooshSheet *SpriteSheet PlaySoundEffects = true AIBroke = false TimeRanOut = false )
var GameServer *network.GameServer
Functions ¶
func ChoosePosition ¶
ChoosePosition determines if the ship can fit in the spot given, including turning the ship vertically. Otherwise returns false
func HandleConnection ¶
func PlayerChoosePosition ¶
PlayerChoosePosition determines if the ship can fit in the spot given with the given orientation
func SetBGMVolume ¶
func SetBGMVolume(volume float64)
Types ¶
type AI ¶
AI represents the computer controlled opponent
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 ¶
ResetBoard removes the current ships and resets them for the given grid
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) 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 (*Character) DrawBustSad ¶
DrawBustSad the character
type EnemyDisplay ¶
type EnemyDisplay struct {
// contains filtered or unexported fields
}
func NewEnemyDisplay ¶
func NewEnemyDisplay(x, y float64, smallGrid bool) *EnemyDisplay
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 (*Game) DrawBackground ¶
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) 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
type GameData ¶
type GameData struct {
// contains filtered or unexported fields
}
GameData contains data for the game
func NewGameData ¶
NewGameData creates a new GameData to keep track of the game
func (*GameData) SetGameMode ¶
SetGameMode sets the game mode chosen by the character. In this case used for Timed mode to set number of bombs
func (*GameData) TimeInMilliseconds ¶
TimeInMilliseconds returns the current time in seconds
func (*GameData) TimeInSecond ¶
TimeInSecond returns the current time in seconds
type GameMain ¶
type GameMain struct { ZoomLevel float64 // contains filtered or unexported fields }
GameMain is 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
type GameOver ¶
type GameOver struct {
// contains filtered or unexported fields
}
GameOver is displayed when the game is over
func CreateGameOver ¶
CreateGameOver creates either a winning screen or losing screen depending on the bool value
func (*GameOver) SetMsg ¶
func (t *GameOver) SetMsg(msg GameStateMsg)
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 ¶
CreateGrid returns a Grid which represents the game field
func (Grid) DetermineTile ¶
DetermineTile returns the value at the grid This is used to use the mouse coords
func (*Grid) ExportNetworkPlacements ¶
func (g *Grid) ExportNetworkPlacements() []*network.PlaceShipType
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) PrintGrid ¶
func (g Grid) PrintGrid()
PrintGrid prints the text representation of the game grid
func (*Grid) RemoveShip ¶
func (Grid) ReturnXYCoords ¶
ReturnXYCoords returns the float values for the given row and col
func (*Grid) SpecialAttack ¶
SpecialAttack is unique to each game character
func (*Grid) UpdatePlacement ¶
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 (*MPBattle) Msg ¶
func (gm *MPBattle) Msg() GameStateMsg
Msg returns the current state's message
func (*MPBattle) SendMessage ¶
func (*MPBattle) SendShipPlacements ¶
func (gm *MPBattle) SendShipPlacements(p *Player, shipPlacements []*network.PlaceShipType)
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) LostConnection ¶
func (t *MPGameOver) LostConnection()
func (*MPGameOver) SetMsg ¶
func (t *MPGameOver) SetMsg(msg GameStateMsg)
type MPHelp ¶
type MPHelp struct {
// contains filtered or unexported fields
}
func CreateMPHelp ¶
func (*MPHelp) Msg ¶
func (t *MPHelp) Msg() GameStateMsg
func (*MPHelp) SetMsg ¶
func (t *MPHelp) SetMsg(msg GameStateMsg)
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 (*MPRooms) AddRooms ¶
AddRooms returns all the available rooms from the server and number of people in each one
func (*MPRooms) Msg ¶
func (t *MPRooms) Msg() GameStateMsg
func (*MPRooms) SetMsg ¶
func (t *MPRooms) SetMsg(msg GameStateMsg)
type MPSetIP ¶
type MPSetIP struct {
// contains filtered or unexported fields
}
func CreateMPSetIP ¶
func (*MPSetIP) Msg ¶
func (t *MPSetIP) Msg() GameStateMsg
func (*MPSetIP) SetMsg ¶
func (t *MPSetIP) SetMsg(msg GameStateMsg)
type MPStage ¶
type MPStage struct {
// contains filtered or unexported fields
}
func CreateMPStage ¶
func (*MPStage) Msg ¶
func (t *MPStage) Msg() GameStateMsg
func (*MPStage) SetMsg ¶
func (t *MPStage) SetMsg(msg GameStateMsg)
type MainMenu ¶
type MainMenu struct {
// contains filtered or unexported fields
}
func CreateMainMenu ¶
func (*MainMenu) Msg ¶
func (t *MainMenu) Msg() GameStateMsg
func (*MainMenu) SetMsg ¶
func (t *MainMenu) SetMsg(msg GameStateMsg)
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) SetMsg ¶
func (t *Paused) SetMsg(msg GameStateMsg)
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player represents the player
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 ¶
CreateShip at point (x,y) or type shipType
func (*Ship) ReturnHitCount ¶
ReturnHitCount returns the number of hits the ship can take before sinking
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) Msg ¶
func (t *TitleMain) Msg() GameStateMsg
func (*TitleMain) SetMsg ¶
func (t *TitleMain) SetMsg(msg GameStateMsg)
Source Files ¶
- ai.go
- audio.go
- background.go
- bulletcounter.go
- character.go
- charselect.go
- game.go
- gamebattle.go
- gamedata.go
- gamemain.go
- gameover.go
- gamestate.go
- grid.go
- mainmenu.go
- mpbattle.go
- mpconfigjoin.go
- mpconnections.go
- mpgameover.go
- mphelp.go
- mplostconnection.go
- mpmainmenu.go
- mprooms.go
- mproomstaging.go
- mpsetip.go
- mpstaging.go
- paused.go
- player.go
- remaining.go
- ship.go
- spritesheet.go
- title.go