game

package
Version: v0.0.0-...-8b49de5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoneWall  rune = '#'
	DirtFloor       = '.'
	ClosedDoor      = '|'
	OpenDoor        = '/'
	UpStair         = 'u'
	DownStair       = 'd'
	Blank           = 0
	Pending         = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	Entity
	Hitpoints    int
	Strength     int
	Speed        float64
	ActionPoints float64
	SightRange   int
	Items        []*Item
	Helmet       *Item
	Weapon       *Item
}

type Entity

type Entity struct {
	Pos
	Name string
	Rune rune
}

type Game

type Game struct {
	LevelChans   []chan *Level
	InputChan    chan *Input
	Levels       map[string]*Level
	CurrentLevel *Level
}

func NewGame

func NewGame(numWindows int) *Game

func (*Game) Move

func (game *Game) Move(to Pos)

func (*Game) Run

func (game *Game) Run()

type GameEvent

type GameEvent int
const (
	Move GameEvent = iota
	DoorOpen
	Attack
	Hit
	Portal
	PickUp
	Drop
)

type Input

type Input struct {
	Typ          InputType
	Item         *Item
	LevelChannel chan *Level
}

type InputType

type InputType int
const (
	None InputType = iota
	Up
	Down
	Left
	Right
	TakeAll
	TakeItem
	DropItem
	EquipItem
	QuitGame
	CloseWindow
	Search //temporary
)

type Item

type Item struct {
	Typ ItemType
	Entity
	// contains filtered or unexported fields
}

func NewHelmet

func NewHelmet(p Pos) *Item

func NewSword

func NewSword(p Pos) *Item

type ItemType

type ItemType int
const (
	Weapon ItemType = iota
	Helmet
	Other
)

type Level

type Level struct {
	Map       [][]Tile
	Player    *Player
	Monsters  map[Pos]*Monster
	Items     map[Pos][]*Item
	Portals   map[Pos]*LevelPos
	Events    []string
	EventPos  int
	Debug     map[Pos]bool
	LastEvent GameEvent
}

func (*Level) AddEvent

func (level *Level) AddEvent(event string)

func (*Level) Attack

func (level *Level) Attack(c1, c2 *Character)

func (*Level) DropItem

func (level *Level) DropItem(itemToDrop *Item, character *Character)

func (*Level) MoveItem

func (level *Level) MoveItem(itemToMove *Item, character *Character)

type LevelPos

type LevelPos struct {
	*Level
	Pos
}

type Monster

type Monster struct {
	Character
}

func NewRat

func NewRat(p Pos) *Monster

func NewSpider

func NewSpider(p Pos) *Monster

func (*Monster) Kill

func (m *Monster) Kill(level *Level)

func (*Monster) Move

func (m *Monster) Move(to Pos, level *Level)

func (*Monster) Pass

func (m *Monster) Pass()

func (*Monster) Update

func (m *Monster) Update(level *Level)

type Player

type Player struct {
	Character
}

type Pos

type Pos struct {
	X, Y int
}

type Tile

type Tile struct {
	Rune        rune
	OverlayRune rune
	Visible     bool
	Seen        bool
}

Jump to

Keyboard shortcuts

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