gameobjects

package
v0.0.0-...-2924a1e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bomb

type Bomb struct {
	*Creature
	// contains filtered or unexported fields
}

func NewBomb

func NewBomb(broadcast chan *z.Message, rooms z.IRooms) *Bomb

func (*Bomb) Body

func (b *Bomb) Body()

func (*Bomb) Explode

func (b *Bomb) Explode(broadcast bool)

func (*Bomb) Run

func (b *Bomb) Run(broadcast bool)

type Creature

type Creature struct {
	*GameObject

	WorldWidth  int
	WorldHeight int

	NextX    int
	NextY    int
	Health   int
	Strength int
	Treasure int
	Stuck    bool
	// contains filtered or unexported fields
}

func NewCreature

func NewCreature(broadcast chan *z.Message, worldWidth, worldHeight int, rooms z.IRooms) *Creature

func (*Creature) Battle

func (c *Creature) Battle(fight func(z.ICreature))

func (*Creature) ChangeHealth

func (c *Creature) ChangeHealth(broadcast bool, health int)

func (*Creature) ChangeStrength

func (c *Creature) ChangeStrength(broadcast bool, strength int)

func (*Creature) ChangeTreasure

func (c *Creature) ChangeTreasure(broadcast bool, treasure int)

func (*Creature) Dead

func (c *Creature) Dead() bool

func (*Creature) GetHealth

func (c *Creature) GetHealth() int

func (*Creature) GetNext

func (c *Creature) GetNext() (int, int)

func (*Creature) GetStrength

func (c *Creature) GetStrength() int

func (*Creature) GetTreasure

func (c *Creature) GetTreasure() int

func (*Creature) Halted

func (c *Creature) Halted() bool

func (*Creature) LoadRooms

func (c *Creature) LoadRooms(rooms z.IRooms)

func (*Creature) Move

func (c *Creature) Move(broadcast bool, nextX, nextY int)

func (*Creature) Next

func (c *Creature) Next(broadcast bool, x, y int)

func (*Creature) Release

func (c *Creature) Release(broadcast bool)

func (*Creature) Stay

func (c *Creature) Stay(broadcast bool)

type GameObject

type GameObject struct {
	sync.RWMutex

	Paused  bool
	Removed bool

	Class  string
	Name   string
	Symbol rune
	Color  tb.Attribute
	X      int
	Y      int
	ID     string
	// contains filtered or unexported fields
}

func NewGameObject

func NewGameObject(broadcast chan *z.Message) *GameObject

func (*GameObject) Body

func (g *GameObject) Body()

func (*GameObject) Delete

func (g *GameObject) Delete(broadcast bool)

func (*GameObject) Deleted

func (g *GameObject) Deleted() bool

func (*GameObject) Event

func (g *GameObject) Event(action string) *z.Message

func (*GameObject) GetClass

func (g *GameObject) GetClass() string

func (*GameObject) GetColor

func (g *GameObject) GetColor() tb.Attribute

func (*GameObject) GetID

func (g *GameObject) GetID() string

func (*GameObject) GetName

func (g *GameObject) GetName() string

func (*GameObject) GetPosition

func (g *GameObject) GetPosition() (int, int)

func (*GameObject) GetSymbol

func (g *GameObject) GetSymbol() rune

func (*GameObject) JSON

func (g *GameObject) JSON() ([]byte, error)

func (*GameObject) Loop

func (g *GameObject) Loop(sleepMain, sleepPaused int, body func())

func (*GameObject) Run

func (g *GameObject) Run(broadcast bool)

func (*GameObject) Running

func (g *GameObject) Running() bool

func (*GameObject) SetColor

func (g *GameObject) SetColor(color tb.Attribute)

func (*GameObject) SetID

func (g *GameObject) SetID(broadcast bool, id string)

func (*GameObject) SetName

func (g *GameObject) SetName(broadcast bool, name string)

func (*GameObject) SetPosition

func (g *GameObject) SetPosition(broadcast bool, x, y int)

func (*GameObject) Start

func (g *GameObject) Start(broadcast bool)

func (*GameObject) Stop

func (g *GameObject) Stop(broadcast bool)

type Health

type Health struct {
	*Item
}

func NewHealth

func NewHealth(broadcast chan *z.Message) *Health

type Item

type Item struct {
	*GameObject
	Points int
}

func NewItem

func NewItem(broadcast chan *z.Message) *Item

func (*Item) GetPoints

func (i *Item) GetPoints() int

type Missle

type Missle struct {
	*Creature

	NextX int
	NextY int
	// contains filtered or unexported fields
}

func NewMissle

func NewMissle(b bool, broadcast chan *z.Message, gameID string, worldWidth, worldHeight int, rooms z.IRooms, class, id string, x, y, nextX, nextY int) *Missle

func (*Missle) Body

func (m *Missle) Body()

func (*Missle) Flash

func (m *Missle) Flash()

func (*Missle) GetNext

func (m *Missle) GetNext() (int, int)

func (*Missle) Move

func (m *Missle) Move(broadcast bool, nextX, nextY int)

func (*Missle) Run

func (m *Missle) Run(broadcast bool)

type Monster

type Monster struct {
	*Creature

	PlayerID   string
	Difficulty int
	// contains filtered or unexported fields
}

func NewMonster

func NewMonster(broadcast chan *z.Message, worldWidth, worldHeight int, rooms z.IRooms, players z.IGameObjectMap, difficulty int) *Monster
func (m *Monster) Blink()

func (*Monster) Body

func (m *Monster) Body()

func (*Monster) LoadPlayer

func (m *Monster) LoadPlayer()

func (*Monster) LoadPlayers

func (m *Monster) LoadPlayers(players z.IGameObjectMap)

func (*Monster) Run

func (m *Monster) Run(broadcast bool)

func (*Monster) SetPlayer

func (m *Monster) SetPlayer(broadcast bool, id string)

type Player

type Player struct {
	*Creature
}

func NewPlayer

func NewPlayer(b bool, broadcast chan *z.Message, gameID string, worldWidth, worldHeight int, rooms z.IRooms, name, id string, symbol rune, color tb.Attribute) *Player

func (*Player) Body

func (p *Player) Body()

func (*Player) Collect

func (p *Player) Collect(broadcast bool)

func (*Player) Run

func (p *Player) Run(broadcast bool)

type Portal

type Portal struct {
	*Creature
}

func NewPortal

func NewPortal(broadcast chan *z.Message, worldWidth, worldHeight int, rooms z.IRooms) *Portal

func (*Portal) Body

func (p *Portal) Body()

func (*Portal) Run

func (p *Portal) Run(broadcast bool)

func (*Portal) Teleport

func (p *Portal) Teleport(c z.ICreature)

type Room

type Room struct {
	*GameObject

	GameObjects map[z.IGameObject]z.IGameObject
	Capacity    int

	sync.RWMutex
}

func NewRoom

func NewRoom(broadcast chan *z.Message, capacity, x, y int) *Room

func (*Room) Enter

func (r *Room) Enter(broadcast bool, g z.IGameObject)

func (*Room) GetCreatures

func (r *Room) GetCreatures() []z.ICreature

func (*Room) GetGameObjects

func (r *Room) GetGameObjects() []z.IGameObject

func (*Room) GetHealths

func (r *Room) GetHealths() []z.IHealth

func (*Room) GetStrengths

func (r *Room) GetStrengths() []z.IStrength

func (*Room) GetTreasures

func (r *Room) GetTreasures() []z.ITreasure

func (*Room) HasRoom

func (r *Room) HasRoom() bool

func (*Room) HasRoomForTwo

func (r *Room) HasRoomForTwo() bool

func (*Room) Leave

func (r *Room) Leave(broadcast bool, g z.IGameObject)

type Strength

type Strength struct {
	*Item
}

func NewStrength

func NewStrength(broadcast chan *z.Message) *Strength

type Treasure

type Treasure struct {
	*Item
}

func NewTreasure

func NewTreasure(broadcast chan *z.Message) *Treasure

Jump to

Keyboard shortcuts

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