game

package
v0.0.0-...-123b542 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GAME_TITLE              = "Go Dino!"
	WINDOW_WIDTH            = 800
	WINDOW_HEIGHT           = 600
	PLATFORM_MIN_SPEED      = 10
	PLATFORM_MAX_SPEED      = 15
	SPEED_INCREASE_INTERVAL = 1000
	CACTUS_START_X          = 900
	CACTUS_MIN_DIST         = 450
	CACTUS_MAX_DIST         = 650
)

Variables

View Source
var (
	EntityGround *Ground
	EntityDino   *Dino
	EntityCactus *Cactus
)

Functions

func LoadEntities

func LoadEntities() error

func Run

func Run(f embed.FS)

Types

type Cactus

type Cactus struct {
	X1       int
	X2       int
	Y        int
	MinDist  int
	Speed    int
	Counter  int
	Sprite   *ebiten.Image
	Options1 *ebiten.DrawImageOptions
	Options2 *ebiten.DrawImageOptions
}

func (*Cactus) Draw

func (c *Cactus) Draw(screen *ebiten.Image)

func (*Cactus) Load

func (c *Cactus) Load() error

func (*Cactus) Update

func (c *Cactus) Update(g *Game)

type Dino

type Dino struct {
	X                int
	Y                int
	InitialHeight    int
	Counter          int
	Tick             int
	JumpSpeed        int
	JumpHeight       int
	JumpMaxHeight    int
	JumpDirection    int
	State            DinoState
	SpriteRun0       *ebiten.Image
	SpriteCurrent    *ebiten.Image
	SpriteRun1       *ebiten.Image
	SpriteLose       *ebiten.Image
	SpriteStationary *ebiten.Image
	Options          *ebiten.DrawImageOptions
}

func (*Dino) Draw

func (d *Dino) Draw(screen *ebiten.Image)

func (*Dino) Load

func (d *Dino) Load() error

func (*Dino) Update

func (d *Dino) Update(g *Game)

type DinoState

type DinoState int
const (
	StateRunning    DinoState = iota
	StateJumping    DinoState = iota
	StateStationary DinoState = iota
)

type Game

type Game struct {
	Score     int
	HighScore int
	State     GameState
	// contains filtered or unexported fields
}

func (*Game) Draw

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

func (*Game) Layout

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

func (*Game) Update

func (g *Game) Update() error

type GameState

type GameState int
const (
	GameStateRunning GameState = iota
	GameStateLost    GameState = iota
)

type Ground

type Ground struct {
	X1       int
	X2       int
	Y        int
	Speed    int
	Counter  int
	Sprite   *ebiten.Image
	Options1 *ebiten.DrawImageOptions
	Options2 *ebiten.DrawImageOptions
}

func (*Ground) Draw

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

func (*Ground) Load

func (g *Ground) Load() error

func (*Ground) Update

func (g *Ground) Update(game *Game)

Jump to

Keyboard shortcuts

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