Documentation ¶
Index ¶
- Constants
- Variables
- func ContainsRune(s []rune, e rune) bool
- func ContainsString(s []string, e string) bool
- func ContainsTermboxKey(s []termbox.Key, e termbox.Key) bool
- func Init(level int)
- func MinInt(a, b int) int
- func ParseLine(l string) []rune
- func ParseTileMapString(tileMap string) [][]rune
- type Canvas
- func (c Canvas) CheckCollision(x, y int) bool
- func (c Canvas) GetCellAt(x, y int) *TermBoxCell
- func (c *Canvas) IsInLastColumn(x int) bool
- func (c *Canvas) IsInsideOfBoundaries(x, y int) bool
- func (c *Canvas) OverWriteCanvasCell(x, y int, termboxCell *TermBoxCell)
- func (c *Canvas) SetCellAt(row, column int, cell *TermBoxCell)
- type Class
- type Direction
- type Entity
- func (e *Entity) Destroy()
- func (e *Entity) GetCells() []*TermBoxCell
- func (e *Entity) GetDrawPriority() int
- func (e *Entity) GetPosition() (int, int)
- func (e *Entity) GetPositionX() int
- func (e *Entity) GetPositionY() int
- func (e *Entity) GetScreenOffset() (int, int)
- func (e *Entity) GetStage() *Stage
- func (e *Entity) GetTags() []Tag
- func (e *Entity) IsInsideOfCanvasBoundaries() bool
- func (e *Entity) SetCells(s *Stage)
- func (e *Entity) SetPosition(x, y int)
- func (e *Entity) SetPositionX(x int)
- func (e *Entity) SetPositionY(y int)
- func (e *Entity) SetStage(s *Stage)
- func (e *Entity) Update(s *Stage, event termbox.Event, time time.Duration)
- type EntityOptions
- type Game
- type GameOptions
- type Level
- func (l *Level) GetScreenOffset() (int, int)
- func (l *Level) GetSize() (int, int)
- func (l *Level) GetTileMapDimensions() (int, int)
- func (l *Level) InitDefaults()
- func (l *Level) LoadTileMap()
- func (l *Level) LoadTileMapCells(parsedRunes [][]rune) [][]*TermBoxCell
- func (l *Level) SetCells(s *Stage)
- func (l *Level) Update(s *Stage, t time.Duration)
- type Logger
- type Point
- type Renderer
- type Stage
- func (s *Stage) AddCanvasEntity(e ...Renderer)
- func (s *Stage) AddScreenEntity(e ...Renderer)
- func (s *Stage) AddTypedEntity(e ...Renderer)
- func (s *Stage) CheckCollision(x, y int) bool
- func (s *Stage) ClearCanvasEntities()
- func (s *Stage) ClearTileMapCellsAt(positions [][2]int)
- func (s *Stage) GetDefaultBgCell() *TermBoxCell
- func (s *Stage) GetRendererEntityByTag(wantedTag Tag) Renderer
- func (s *Stage) Init()
- func (s *Stage) Render()
- func (s *Stage) Reset()
- func (s *Stage) Resize(w, h int)
- func (s *Stage) SetCanvasBackgroundCells()
- func (s *Stage) SetGame(game *Game)
- func (s *Stage) SetLevel(levelInstance *Level)
- func (s *Stage) TermboxSetCanvasCells()
- func (s *Stage) TermboxSetCell(x, y int, cell *TermBoxCell, offset bool)
- func (s *Stage) TermboxSetCursorCell()
- func (s *Stage) TermboxSetScreenCells()
- func (s *Stage) TermboxSetTypedCells()
- type Tag
- type TermBoxCell
- type TileMapCellData
- type TileMapCellDataMap
- type User
- type VimManEvent
- type VimMode
- type Word
- type WordOptions
Constants ¶
const LevelBasicMovementTileMapString = `` /* 1306-byte string literal not displayed */
const LevelBombermanTileMapString = `` /* 515-byte string literal not displayed */
const LevelExitingVimTileMapString = `` /* 1365-byte string literal not displayed */
const LevelTextEditingTileMapString = `` /* 1365-byte string literal not displayed */
Variables ¶
var CommonTileMapCellData = TileMapCellDataMap{ '0': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: ' ', CollidesPhysically: false, CollisionCallback: func() {}, }, '↓': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '↓', CollidesPhysically: false, CollisionCallback: func() {}, }, '+': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '+', CollidesPhysically: true, CollisionCallback: func() {}, }, '-': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '-', CollidesPhysically: true, CollisionCallback: func() {}, }, '|': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '|', CollidesPhysically: true, CollisionCallback: func() {}, }, '█': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '█', CollidesPhysically: true, CollisionCallback: func() {}, }, '◼': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '◼', CollidesPhysically: true, CollisionCallback: func() {}, }, '▅': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '▅', CollidesPhysically: true, CollisionCallback: func() {}, }, '▀': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '▀', CollidesPhysically: true, CollisionCallback: func() {}, }, '☵': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '☵', CollidesPhysically: true, CollisionCallback: func() {}, }, '☲': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: '☲', CollidesPhysically: true, CollisionCallback: func() {}, }, ' ': { BgColor: termbox.ColorBlack, FgColor: termbox.ColorWhite, Ch: ' ', CollidesPhysically: false, CollisionCallback: func() {}, }, }
Functions ¶
func ContainsRune ¶
func ContainsString ¶
func ContainsTermboxKey ¶
func ContainsTermboxKey(s []termbox.Key, e termbox.Key) bool
func ParseTileMapString ¶
Types ¶
type Canvas ¶
type Canvas [][]*TermBoxCell
func (Canvas) CheckCollision ¶
func (Canvas) GetCellAt ¶
func (c Canvas) GetCellAt(x, y int) *TermBoxCell
func (*Canvas) IsInLastColumn ¶
func (*Canvas) IsInsideOfBoundaries ¶
func (*Canvas) OverWriteCanvasCell ¶
func (c *Canvas) OverWriteCanvasCell(x, y int, termboxCell *TermBoxCell)
func (*Canvas) SetCellAt ¶
func (c *Canvas) SetCellAt(row, column int, cell *TermBoxCell)
type Entity ¶
type Entity struct { Stage *Stage Position Point Width int Height int Rune rune Cell *TermBoxCell Cells []*TermBoxCell DrawPriority int Tags []Tag InitCallback func() }
func NewEntity ¶
func NewEntity(s *Stage, x, y, w, h int, r rune, fg termbox.Attribute, bg termbox.Attribute, cells []*TermBoxCell, collidesPhysically bool, options EntityOptions) *Entity
func (*Entity) GetCells ¶
func (e *Entity) GetCells() []*TermBoxCell
func (*Entity) GetDrawPriority ¶
func (*Entity) GetPosition ¶
func (*Entity) GetPositionX ¶
func (*Entity) GetPositionY ¶
func (*Entity) GetScreenOffset ¶
func (*Entity) IsInsideOfCanvasBoundaries ¶
func (*Entity) SetPosition ¶
func (*Entity) SetPositionX ¶
func (*Entity) SetPositionY ¶
type EntityOptions ¶
type Game ¶
type Game struct { Stage *Stage VimManEvents chan VimManEvent // contains filtered or unexported fields }
func NewGame ¶
func NewGame(opts GameOptions) *Game
type GameOptions ¶
type GameOptions struct { VimManEvents chan VimManEvent // contains filtered or unexported fields }
type Level ¶
type Level struct { Game *Game VimMode VimMode TileMapString string TileMap [][]*TermBoxCell TileData TileMapCellDataMap Entities []Renderer InputRunes []rune BlockedKeys []termbox.Key InputBlocked bool TextShiftingDisabled bool BgCell *termbox.Cell Width int Height int Init func() ColonLineCallbacks map[string]func(game *Game) }
func NewLevelBasicMovement ¶
func NewLevelBomberman ¶
func NewLevelExitingVim ¶
func NewLevelTextEditing ¶
func (*Level) GetScreenOffset ¶
func (*Level) InitDefaults ¶
func (l *Level) InitDefaults()
func (*Level) LoadTileMap ¶
func (l *Level) LoadTileMap()
func (*Level) LoadTileMapCells ¶
func (l *Level) LoadTileMapCells(parsedRunes [][]rune) [][]*TermBoxCell
type Renderer ¶
type Renderer interface { Update(*Stage, termbox.Event, time.Duration) Destroy() SetCells(*Stage) GetCells() []*TermBoxCell GetPosition() (int, int) GetPositionX() int GetPositionY() int SetPositionX(int) GetScreenOffset() (int, int) GetDrawPriority() int GetTags() []Tag ShouldCenterHorizontally() bool }
type Stage ¶
type Stage struct { Game *Game Level int LevelInstance *Level Fps float64 CanvasEntities []Renderer // entities to be rendered in canvas ScreenEntities []Renderer // entities to be rendered outside of the canvas TypedEntities []Renderer BgCell *termbox.Cell Canvas Canvas Width int Height int ModeLabel *Word ColonLine *Word // contains filtered or unexported fields }
holds the current level meta data, canvas and entities
func (*Stage) AddCanvasEntity ¶
func (*Stage) AddScreenEntity ¶
func (*Stage) AddTypedEntity ¶
func (*Stage) CheckCollision ¶
func (*Stage) ClearCanvasEntities ¶
func (s *Stage) ClearCanvasEntities()
func (*Stage) ClearTileMapCellsAt ¶
clear Canvas cell and TileMap cell at the given positions
func (*Stage) GetDefaultBgCell ¶
func (s *Stage) GetDefaultBgCell() *TermBoxCell
func (*Stage) GetRendererEntityByTag ¶
func (*Stage) Render ¶
func (s *Stage) Render()
this function handles all the rendering sets and renders in order: tilemap cells: the background cells canvas entities: canvas entities, they have update methods that gets called on stage.update method screen cells: cells outside of the canvas such as level label and instructions
func (*Stage) SetCanvasBackgroundCells ¶
func (s *Stage) SetCanvasBackgroundCells()
sets the background cells to be rendered, this gets rendered first in the render method so that other cells can be overwritten into the same location
func (*Stage) TermboxSetCanvasCells ¶
func (s *Stage) TermboxSetCanvasCells()
sets the cells inside the canvas, offset is being applied in order to keep the canvas in center
func (*Stage) TermboxSetCell ¶
func (s *Stage) TermboxSetCell(x, y int, cell *TermBoxCell, offset bool)
calls termbox.setCell, sets the coordinates and the cell attributes this does the actual rendering of the characters, thanks to termbox-go <3
func (*Stage) TermboxSetCursorCell ¶
func (s *Stage) TermboxSetCursorCell()
func (*Stage) TermboxSetScreenCells ¶
func (s *Stage) TermboxSetScreenCells()
sets the cells outside of the canvas, no offset is being applied
func (*Stage) TermboxSetTypedCells ¶
func (s *Stage) TermboxSetTypedCells()
type TermBoxCell ¶
type TermBoxCell struct { *termbox.Cell // contains filtered or unexported fields }
func ConvertStringToCells ¶
func ConvertStringToCells(s string, fg termbox.Attribute, bg termbox.Attribute) []*TermBoxCell
func EmptyTileMapCell ¶
func EmptyTileMapCell() *TermBoxCell
type TileMapCellData ¶
type TileMapCellData struct { Ch rune BgColor termbox.Attribute FgColor termbox.Attribute CollidesPhysically bool CollisionCallback func() InitCallback func(*Entity) LineNumber int }
func NewTileMapCell ¶
func NewTileMapCell(ch rune, fn func(), lineNumber int) TileMapCellData
type TileMapCellDataMap ¶
type TileMapCellDataMap map[rune]TileMapCellData
type VimManEvent ¶
type VimManEvent struct {
Content string
}
type Word ¶
type Word struct { *Entity Content string Speed float64 Direction Direction CenterHorizontally bool Fg termbox.Attribute Bg termbox.Attribute }
func NewEmptyCharacter ¶
func NewEmptyCharacter(s *Stage, x, y int, options WordOptions) *Word
func (*Word) ShouldCenterHorizontally ¶
type WordOptions ¶
type WordOptions struct { InitCallback func() Fg termbox.Attribute Bg termbox.Attribute CollidesPhysically bool CenterHorizontally bool Tags []Tag }
func DefaultWordOptions ¶
func DefaultWordOptions() WordOptions