roguelike

package
v0.0.0-...-6be291f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity interface {
	X() int
	Y() int
	Icon() rune
	Color() termbox.Attribute

	Move(int, int)
	Render()
	Clear()
}

func NewEntity

func NewEntity(x, y int, icon rune, color termbox.Attribute) Entity

type Game

type Game struct {
	Running    bool
	EventQueue chan termbox.Event
	Level      Level
	Player     Entity
	Entities   []Entity
}

Game is our container for all game data. We bind methods to it in order to avoid creating global variables and global state.

func (*Game) HandleInput

func (g *Game) HandleInput(ev termbox.Event)

HandleInput processes termbox events and changes game state accordingly.

func (*Game) Main

func (g *Game) Main()

Main is the game's core loop. It is expected to be run from a main package until g.Running is set to false by the game.

func (*Game) Setup

func (g *Game) Setup() error

Setup performs one-time tasks at startup in order to initialize the game.

type Level

type Level interface {
	Tiles() [][]Tile
	IsBlocked(x, y int) bool
	Render()
}

func NewLevel

func NewLevel(w, h int) Level

type Tile

type Tile interface {
	IsBlocked() bool
	IsOpaque() bool

	SetBlocked()
	SetOpaque()
}

func NewTile

func NewTile(blocked, opaque bool) Tile

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL