Documentation
¶
Overview ¶
Package lettersnake contains game logic.
Index ¶
- Constants
- type Game
- func (g *Game) ConsumedLetters() string
- func (g *Game) CurrentTranslation() string
- func (g *Game) CurrentWord() string
- func (g *Game) Direction() int
- func (g *Game) IsPlayAreaSizeSet() bool
- func (g *Game) Iterate() int
- func (g *Game) Letters() *map[int]map[int]rune
- func (g *Game) NumCorrectGuesses() int
- func (g *Game) NumUsedWords() int
- func (g *Game) NumWordList() int
- func (g *Game) RandomizeWords()
- func (g *Game) ReadWords(f io.Reader)
- func (g *Game) SetDirection(direction int)
- func (g *Game) SetPlayAreaSize(width int, height int)
- func (g *Game) Snake() []Segment
- func (g *Game) StartGame()
- func (g *Game) State() int
- func (g *Game) StopGame()
- func (g *Game) Tail() *Segment
- func (g *Game) WordListTitle() string
- type Letter
- type Segment
Constants ¶
const ( // NotStarted indicates that the game has not started yet. NotStarted = iota // GameOn indicates that the game is currently in progress. GameOn // GameOver indicates that the game has ended. GameOver )
Game state.
const ( // MovingDown indicates that the snake is moving downward. MovingDown = iota // MovingUp indicates that the snake is moving upward. MovingUp // MovingLeft indicates that the snake is moving to the left. MovingLeft // MovingRight indicates that the snake is moving to the right. MovingRight )
Direction represents the direction in which the snake is moving.
const ( // EdgeHit indicates that the snake has hit the edge of the screen. EdgeHit // AteItself indicates that the snake has collided with its own body. AteItself // AllWordsUsed means all words in the list have already been used. AllWordsUsed // ContinueGame indicates that the game should continue running. ContinueGame )
Game iteration result.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game holds the state and data of the game.
func (*Game) ConsumedLetters ¶
ConsumedLetters returns letters that have been consumed by the snake so far.
func (*Game) CurrentTranslation ¶
CurrentTranslation returns the translation of the current word.
func (*Game) CurrentWord ¶
CurrentWord returns the current word that is being guessed by the player.
func (*Game) IsPlayAreaSizeSet ¶ added in v0.5.0
IsPlayAreaSizeSet determines whether the play area size was set.
func (*Game) NumCorrectGuesses ¶ added in v0.5.0
NumCorrectGuesses returns the number of correctly guessed words.
func (*Game) NumUsedWords ¶
NumUsedWords returns the number of words used so far in the game.
func (*Game) NumWordList ¶ added in v0.5.0
NumWordList returns the total number of words in the input list.
func (*Game) RandomizeWords ¶
func (g *Game) RandomizeWords()
RandomizeWords reorders the word list in a random order.
func (*Game) SetDirection ¶
SetDirection changes direction snake is moving.
func (*Game) SetPlayAreaSize ¶ added in v0.5.0
SetPlayAreaSize sets size of the play area on which the snake can move.
func (*Game) StartGame ¶
func (g *Game) StartGame()
StartGame resets all game variables and starts a new game.
func (*Game) WordListTitle ¶ added in v0.5.0
WordListTitle returns title of the word list.