game

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BoxSize = 5

BoxSize is based on the box sprite visual dimensions

View Source
const ProjSize = 2 // How big a projectile's hitbox is
View Source
const TailDist = 1 // Distance between projectile and tail
View Source
const TailMax = 10 // Maximum length of projectile tail

Variables

View Source
var Context *audio.Context
View Source
var HighScore int = 0

Using globals vs meeting deadlines

Functions

func IsMainActionButtonPressed

func IsMainActionButtonPressed(TouchIDs *[]ebiten.TouchID) bool

Main action button is 5, like in the middle of a Nokia 3310 Fallbacks for people without a numpad:

  • Spacebar on desktop
  • Tap the screen on mobile

func NewTextRenderer added in v0.4.0

func NewTextRenderer() *etxt.Renderer

Types

type Box

type Box struct {
	Coords image.Point
	Chute  bool

	HitBox image.Rectangle
	State  boxAnimationTags // Current animation state
	Frame  int              // Current animation frame
	Sprite *assets.SpriteSheet
	Tick   int
	// contains filtered or unexported fields
}

Box is the player character in the game

func NewBox

func NewBox(coords image.Point, size int) *Box

func (*Box) Draw

func (b *Box) Draw(screen *ebiten.Image)

func (*Box) Pull

func (b *Box) Pull()

Move moves the player upwards

func (*Box) Update

func (b *Box) Update() error

type Dust

type Dust struct {
	Coords image.Point
}

Dust is decorative dirt on the screen to give the illusion of motion

func (*Dust) MoveUp

func (d *Dust) MoveUp()

func (*Dust) Update

func (d *Dust) Update()

type Dusts

type Dusts []*Dust

func (*Dusts) Draw

func (ds *Dusts) Draw(screen *ebiten.Image)

func (*Dusts) Drop

func (ds *Dusts) Drop(i int)

func (*Dusts) MoveUp

func (ds *Dusts) MoveUp()

func (*Dusts) Update

func (ds *Dusts) Update()

type EOS

type EOS struct {
	NextScreen Screen
}

EOS is an End Of Screen error This means the screen's logic has terminated and the controlling game should switch to a different screen

func (*EOS) Error

func (e *EOS) Error() string

type Entity

type Entity interface {
	Update() error
	Draw(screen *ebiten.Image)
}

A generic thing that fits into a tree of Ebitengine update-draw calls

type GameScreen

type GameScreen struct {
	Box         *Box
	Dusts       Dusts
	Projectiles Projectiles
	Tick        int
	TouchIDs    *[]ebiten.TouchID
	SFXHit      *audio.Player
}

GameScreen represents state for the game proper

func NewGameScreen

func NewGameScreen(touchIDs *[]ebiten.TouchID) *GameScreen

func (*GameScreen) Draw

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

func (*GameScreen) Update

func (g *GameScreen) Update() error

type Point added in v1.0.1

type Point struct {
	X, Y float64
}

Point is X, Y coordinates in 2D space, like image.Point but with floats

func (*Point) Pt added in v1.0.1

func (p *Point) Pt() image.Point

type Projectile

type Projectile struct {
	Coords   Point
	Tail     int
	Size     int
	Velocity float64 // Direction and speed
	Spacing  int     // How far away to place the next one
}

Projectile is something that flies across the screen and causes damage if it hits the box

func (*Projectile) Draw

func (p *Projectile) Draw(screen *ebiten.Image)

func (*Projectile) MoveUp

func (p *Projectile) MoveUp()

func (*Projectile) Update

func (p *Projectile) Update()

type Projectiles

type Projectiles []*Projectile

func (*Projectiles) Draw

func (ps *Projectiles) Draw(screen *ebiten.Image)

func (*Projectiles) Drop

func (ps *Projectiles) Drop(i int)

func (*Projectiles) MoveUp

func (ps *Projectiles) MoveUp()

func (*Projectiles) Spawn added in v0.3.1

func (ps *Projectiles) Spawn(tick int)

func (*Projectiles) Update

func (ps *Projectiles) Update(tick int)

type Screen

type Screen int

Types of screens/scenes in the game

const (
	ScreenTitle Screen = iota // Shows when the game first starts
	ScreenGame                // The actual game itself
	ScreenMax                 // How many screens there are
)

type TitleScreen

type TitleScreen struct {
	Background   *ebiten.Image
	TouchIDs     *[]ebiten.TouchID
	Music        *audio.Player
	SFXFall      *audio.Player
	Box          *Box
	TextRenderer *etxt.Renderer
}

func NewTitleScreen added in v0.4.0

func NewTitleScreen(touchIDs *[]ebiten.TouchID) *TitleScreen

func (*TitleScreen) Draw

func (t *TitleScreen) Draw(screen *ebiten.Image)

func (*TitleScreen) Update

func (t *TitleScreen) Update() error

Jump to

Keyboard shortcuts

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