Documentation ¶
Overview ¶
Package pacman implements the classic Pacman game, with a procedurally generated, infinite vertical maze.
How to play: Use direction keys to move pacman. Ghosts try to chase player and on collision player looses a life. Player starts with 5 lives and can have upto 7. Collect diamond to increase lives. Use flask to gain ability to destroy ghosts, ability lasts for 10 seconds & ghosts try to runaway from player. Eating a ghost gives bonus of 200 points.
Index ¶
- Constants
- Variables
- func GridView(characters *assets.Characters, powers *assets.Powers, ...) (func(state gameState, data *Data) (*ebiten.Image, error), error)
- func MazeView(walls *assets.Walls) (func(state gameState, data *Data) (*ebiten.Image, error), error)
- func SkinView(skin *ebiten.Image, powers *assets.Powers, arcadeFont *truetype.Font) (func(state gameState, data *Data) (*ebiten.Image, error), error)
- type Audio
- type AudioPlayers
- type Data
- type Game
- type Ghost
- type Maze
- type Pacman
- type Position
- type Power
Constants ¶
const ( North direction = iota East South West )
const ( Ghost1 ghostType = iota Ghost2 Ghost3 Ghost4 )
const ( Life powerType = iota Invincibility )
const ( GameLoading gameState = iota GameStart GamePause GameOver OffsetY = CellSize * 10 )
const CellSize = 64
const Columns = 10
Columns defines the number of cells in a row in maze.
const GridViewSize = 1024
const MagicNumber = 0.7
MagicNumber for deciding whether or not to tear down wall between two columns.
const MaxLifes = 7
const MaxScoreView = 999999999
const MazeViewSize = 1536
Variables ¶
var GrayColor = color.RGBA{236, 240, 241, 255.0}
Functions ¶
Types ¶
type AudioPlayers ¶
type Maze ¶
type Maze struct {
// contains filtered or unexported fields
}
Maze represents a maze of size rows x 10.
Maze creation is based on modified version of Eller's algorithm http://weblog.jamisbuck.org/2010/12/29/maze-generation-eller-s-algorithm. Eller's algorithm creates a perfect maze, a perfect maze has only one path between any two cells. Secondly to create next row, it requires knowledge of current row only. Giving us ability to create maze with infinite rows.
Current implementation has been modified to give a non-perfect maze i.e. it can have more than one path between any two cells.
func NewMaze ¶
NewMaze returns an unintialized maze with given number of rows. Rand source is used for all random operations, to give deterministic results for a given seed.
func NewPopulatedMaze ¶
NewPopulatedMaze returns a valid maze with given number of rows. It calls Populate after calling NewMaze.
func (*Maze) Compact ¶
Compact removes given number of rows from head of grid and also creates walls in South direction to prevent player from acessing previous rows.
func (*Maze) Get ¶
Get returns section of maze specified by indexes. It reorders from & upto if from is greater than upto. In case upto is bigger than number of rows, all rows till last are returned.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package assets contains font, image & sound resources needed by the game
|
Package assets contains font, image & sound resources needed by the game |
fonts
Package fonts contains variables holding font files.
|
Package fonts contains variables holding font files. |
images
Package images contains variables holding image files.
|
Package images contains variables holding image files. |
sounds
Package sounds contains variables holding sound files.
|
Package sounds contains variables holding sound files. |
build
|
|
Package spritetools provides functions to manipulate ebiten images.
|
Package spritetools provides functions to manipulate ebiten images. |