game

package
v0.0.0-...-a8eda97 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TileKindEmpty = 0
	TileKindWall  = 1
	TileKindWood  = 2
)

Variables

View Source
var (
	Zoom         = 2
	ScreenWidth  = 12 * GetTileSize()
	ScreenHeight = 16 * GetTileSize()
)
View Source
var (
	HeaderHeight = 20
)

Functions

func DegreesToRadians

func DegreesToRadians(degrees float64) float64

func Distance

func Distance(a, b Position) float64

func Filter

func Filter(arr []Task, f func(Task) bool) []interface{}

func GetDxDyDir

func GetDxDyDir(a, b *Position) (dx int, dy int, dir joystick.Dir)

func GetEntityTile

func GetEntityTile(g *Game, entity Entity) (*Tile, *Position)

func GetFont

func GetFont(name string) font.Face

func GetResource

func GetResource(name ResourceName) *ebiten.Image

func GetSurroundedTiles

func GetSurroundedTiles(tilePos Position, g *Game) (center, up, left, down, right *Tile, tiles []*Tile, err error)

func GetTileSize

func GetTileSize() int

func LoadResources

func LoadResources() error

func ScaleImage

func ScaleImage(img *ebiten.Image) *ebiten.Image

func SetTimeout

func SetTimeout(t int, f func())

Types

type AllPlayerFeatures

type AllPlayerFeatures = map[int]Features

type Board

type Board struct {
	// contains filtered or unexported fields
}

func GetLevelBoard

func GetLevelBoard(index int) *Board

func NewBoard

func NewBoard(widthSize int, heightSize int, tiles []*Tile) (*Board, error)

func (*Board) Draw

func (b *Board) Draw(boardImage *ebiten.Image) error

func (*Board) Size

func (b *Board) Size() (int, int)

func (*Board) Update

func (b *Board) Update(g *Game) error

type Bomb

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

func NewBomb

func NewBomb(g *Game, x, y, lifeTime int) *Bomb

func (*Bomb) Draw

func (b *Bomb) Draw(boardImage *ebiten.Image) error

func (*Bomb) MakeBombEffects

func (b *Bomb) MakeBombEffects(g *Game) bool

func (*Bomb) Update

func (b *Bomb) Update(g *Game) error

type BombEffect

type BombEffect struct {
	// contains filtered or unexported fields
}

func NewBombEffect

func NewBombEffect(pos Position, playerPosition *Position) *BombEffect

func (*BombEffect) Draw

func (b *BombEffect) Draw(boardImage *ebiten.Image) error

func (*BombEffect) Update

func (b *BombEffect) Update(g *Game) error

type BombState

type BombState string
const (
	BombStateIdle      BombState = "idle"
	BombStateExploding BombState = "exploding"
)

type DefaultImageCords

type DefaultImageCords struct {
	// contains filtered or unexported fields
}

type Enemy

type Enemy struct {
	// contains filtered or unexported fields
}

func NewEnemy

func NewEnemy(pos *Position) *Enemy

func (*Enemy) AllowedTile

func (e *Enemy) AllowedTile(t *Tile) bool

func (*Enemy) Die

func (e *Enemy) Die(g *Game) error

func (*Enemy) Draw

func (e *Enemy) Draw(boardImage *ebiten.Image) error

func (*Enemy) GetFeatures

func (e *Enemy) GetFeatures() Features

func (*Enemy) GetName

func (p *Enemy) GetName() string

func (*Enemy) GetNearTile

func (e *Enemy) GetNearTile(g *Game) *Tile

func (*Enemy) GetPosition

func (p *Enemy) GetPosition() *Position

func (*Enemy) GetSize

func (p *Enemy) GetSize() int

func (*Enemy) Move

func (e *Enemy) Move(g *Game)

func (*Enemy) Update

func (e *Enemy) Update(g *Game) error

type EnemyFamily

type EnemyFamily string
const (
	Chort EnemyFamily = "chort"
	Orc   EnemyFamily = "orc"
)

type EnemyState

type EnemyState string
const (
	EnemyStateIdle   EnemyState = "idle"
	EnemyStateAttack EnemyState = "walk"
	EnemyStateDead   EnemyState = "dead"
)

type Entity

type Entity interface {
	GetPosition() *Position
	GetName() string
	GetSize() int
}

type Features

type Features struct {
	// contains filtered or unexported fields
}

type Game

type Game struct {
	UiComponents map[GameScreen][]ui.Component
	// contains filtered or unexported fields
}

func NewGame

func NewGame() *Game

func (*Game) AddBomb

func (g *Game) AddBomb(pos *Position, lifeTime int)

func (*Game) AddEnemy

func (g *Game) AddEnemy()

func (*Game) AddPickable

func (g *Game) AddPickable(kind PickableEnum)

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

Draw draws the game screen. Draw is called every frame (typically 1/60[s] for 60Hz display).

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

Layout takes the outside size (e.g., the window size) and returns the (logical) screen size. If you don't have to adjust the screen size with the outside size, just return a fixed size.

func (*Game) RemoveBomb

func (g *Game) RemoveBomb(bomb *Bomb)

func (*Game) RemoveEnemy

func (g *Game) RemoveEnemy(enemy *Enemy)

func (*Game) SetScreen

func (g *Game) SetScreen(s GameScreen)

func (*Game) Update

func (g *Game) Update() error

Update proceeds the game state. Update is called every tick (1/60 [s] by default).

type GameScreen

type GameScreen int
const (
	GameScreenPlay GameScreen = iota
	GameScreenGameOver
	GameScreenPause
	GameScreenStart
)
type Header struct {
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader() *Header

func (*Header) Draw

func (h *Header) Draw(image *ebiten.Image)

func (*Header) Update

func (h *Header) Update(g *Game)

type ISprite

type ISprite interface {
	Animate() error
	SetCurrent(*ebiten.Image)
	GetCurrent() *ebiten.Image
	IsAnimation() bool
}

func GetSpriteByKind

func GetSpriteByKind(kind int) ISprite

func NewAnimatedSprite

func NewAnimatedSprite(img *ebiten.Image, length int, line int, tileWidth int, offset *Offsets, scale bool) ISprite

func NewSingleSprite

func NewSingleSprite(img *ebiten.Image, pos *Position, tileWidth int, scale bool) ISprite

type Level

type Level struct {
	// contains filtered or unexported fields
}

type Offsets

type Offsets struct {
	// contains filtered or unexported fields
}

type Pickable

type Pickable struct {
	// contains filtered or unexported fields
}

func NewPickable

func NewPickable(kind PickableEnum, pos *Position) *Pickable

func (*Pickable) Draw

func (p *Pickable) Draw(boardImage *ebiten.Image) error

func (*Pickable) GetKind

func (p *Pickable) GetKind() PickableEnum

func (*Pickable) GetName

func (p *Pickable) GetName() string

func (*Pickable) GetPosition

func (p *Pickable) GetPosition() *Position

func (*Pickable) GetSize

func (p *Pickable) GetSize() int

func (*Pickable) Update

func (p *Pickable) Update(g *Game)

type PickableEnum

type PickableEnum int
const (
	PickableEnumPower PickableEnum = iota
	PickableEnumSpeed
	PickableEnumLife
	PickableEnumMaxItems
)

type Player

type Player struct {
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer() *Player

func (*Player) AddTask

func (p *Player) AddTask(action joystick.Action)

func (*Player) Animate

func (p *Player) Animate(game *Game) error

func (*Player) CurrentImage

func (p *Player) CurrentImage() *ebiten.Image

func (*Player) Die

func (p *Player) Die(g *Game) error

func (*Player) Draw

func (p *Player) Draw(boardImage *ebiten.Image) error

func (*Player) GetFeatures

func (p *Player) GetFeatures() Features

func (*Player) GetName

func (p *Player) GetName() string

func (*Player) GetNextTile

func (p *Player) GetNextTile(g *Game, direction joystick.Dir) *Tile

func (*Player) GetPosition

func (p *Player) GetPosition() *Position

func (*Player) GetSize

func (p *Player) GetSize() int

func (*Player) Move

func (p *Player) Move(g *Game)

func (*Player) RunTasks

func (p *Player) RunTasks(game *Game) error

func (*Player) Update

func (p *Player) Update(game *Game) error

func (*Player) UpgradePlayer

func (p *Player) UpgradePlayer() error

type PlayerState

type PlayerState string
const (
	PlayerStateIdle PlayerState = "idle"
	PlayerStateWalk PlayerState = "walk"
	PlayerStateDie  PlayerState = "die"
)

type Position

type Position struct {
	X int
	Y int
}

func GetTileBoardPos

func GetTileBoardPos(pos *Position) Position

func GetVectorTiles

func GetVectorTiles(vet *Position, center Position, radius int, g *Game) []Position

type PrevEntry

type PrevEntry struct {
	// contains filtered or unexported fields
}

type ResourceName

type ResourceName string
const (
	ResourceNameChortIdle    ResourceName = "chort_idle"
	ResourceNameChostRun     ResourceName = "chort_run"
	ResourceNameDoor         ResourceName = "door"
	ResourceNameWall         ResourceName = "wall"
	ResourceNameWallFountain ResourceName = "wall_fountain"
	ResourceNameLizardIdle   ResourceName = "lizard_idle"
	ResourceNameLizardRun    ResourceName = "lizard_run"
	ResourceNameChestAnim    ResourceName = "chest_anim"
	ResourceNameFlaskBlue    ResourceName = "flask_blue"
	ResourceNameFloor        ResourceName = "floor"
	ResourceNameReplay       ResourceName = "replay"
	ResourceNameBoomIdle     ResourceName = "boom_idle"
	ResourceNameBoomOn       ResourceName = "boom_on"
)

type ScreenOptions

type ScreenOptions struct {
	Draw   func(*Game, *ebiten.Image) error
	Update func(*Game)
	Init   func(*Game)
}

type Sprite

type Sprite struct {
	// contains filtered or unexported fields
}

func (*Sprite) Animate

func (s *Sprite) Animate() error

func (*Sprite) GetCurrent

func (s *Sprite) GetCurrent() *ebiten.Image

func (*Sprite) IsAnimation

func (s *Sprite) IsAnimation() bool

func (*Sprite) Reset

func (s *Sprite) Reset() error

func (*Sprite) SetCurrent

func (s *Sprite) SetCurrent(i *ebiten.Image)

type Task

type Task struct {
	// contains filtered or unexported fields
}

type Tile

type Tile struct {
	// contains filtered or unexported fields
}

func FilterTiles

func FilterTiles(arr []*Tile, f func(*Tile) bool) []*Tile

func GetSurroundedTilesArray

func GetSurroundedTilesArray(tilePos Position, g *Game) ([]*Tile, error)

func GetTileByBoardPosition

func GetTileByBoardPosition(pos *Position, g *Game) *Tile

func NewTile

func NewTile(x, y int, kind int) *Tile

func (*Tile) Draw

func (t *Tile) Draw(boardImage *ebiten.Image) error

func (*Tile) Update

func (t *Tile) Update(g *Game) error

func (*Tile) Walkable

func (t *Tile) Walkable() bool

Jump to

Keyboard shortcuts

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