Documentation
¶
Overview ¶
Package flyweight implement the Flyweight design pattern. The flyweight object Tile is used by the TileFactory to optimize the memory usage for the storing of the renderable Tile items. It encapsulates the logic to create new or return the existing Tile for the client to define and render the optimized GameMap.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GameMap ¶
type GameMap struct {
// contains filtered or unexported fields
}
GameMap represents the map of the game that could be rendered.
func NewGameMap ¶
NewGameMap is the GameMap constructor based on the provided boundaries and the list of Tiles.
type Renderer ¶
type Renderer interface {
Render()
}
Renderer is the common interface for the renderable items of the game.
type Tile ¶
type Tile struct {
Character rune
}
Tile is a flyweight object that represents renderable item on the map.
type TileFactory ¶
type TileFactory struct {
// contains filtered or unexported fields
}
TileFactory implements the flyweight factory for the Tile construction (or the reusage of the existing Tiles).
func (*TileFactory) GetTileType ¶
func (tf *TileFactory) GetTileType(character rune) *Tile
GetTileType returns the existing Tile, or creates the new Tile based on the provided character symbol.