invaders

package
v0.0.0-...-da5c1ea Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArenaMaxWidth  = 100
	ArenaMaxHeight = 37
)

Variables

View Source
var (
	Basic  = AlienType{Source: alienBasicBytes, Points: 10}
	Medium = AlienType{Source: alienMediumBytes, Points: 20}
	Strong = AlienType{Source: alienStrongBytes, Points: 30}
)

Functions

func CreateCanvas

func CreateCanvas(fileContent []byte) tl.Canvas

func SetPositionAndRenderAliens

func SetPositionAndRenderAliens(aliens [][]*Alien, level *tl.BaseLevel, arena *Arena)

func ShowGameOverScreen

func ShowGameOverScreen(invaders *Invaders)

func ShowTitleScreen

func ShowTitleScreen(invaders *Invaders)

Types

type Alien

type Alien struct {
	*tl.Entity
	IsAlive    bool
	IsRendered bool
	Points     int
}

func CreateAliensLine

func CreateAliensLine(alienType AlienType, lineSize int) []*Alien

func NewAlien

func NewAlien(alienType AlienType) *Alien

func (*Alien) Collide

func (alien *Alien) Collide(collision tl.Physical)

type AlienCluster

type AlienCluster struct {
	Aliens                   [][]*Alien
	Lasers                   []*Laser
	TimeToMove               float64
	WaitingTime              float64
	WaitingTimeToMoveNextRow float64
	CurrentRowMoving         int
	Direction                int
	MoveSize                 int
	IsMoving                 bool
	IsMovingDown             bool
	IsAllDead                bool
	ReachedEndArena          bool
}

func NewAlienCluster

func NewAlienCluster() *AlienCluster

func (*AlienCluster) IsAllAliensDead

func (alienCluster *AlienCluster) IsAllAliensDead() bool

func (*AlienCluster) RemoveDeadAliensAndGetPoints

func (alienCluster *AlienCluster) RemoveDeadAliensAndGetPoints(level *tl.BaseLevel) int

func (*AlienCluster) Shoot

func (alienCluster *AlienCluster) Shoot()

func (*AlienCluster) UpdateAliensPositions

func (alienCluster *AlienCluster) UpdateAliensPositions(timeDelta float64, arena *Arena)

type AlienType

type AlienType struct {
	Source []byte
	Points int
}

type Arena

type Arena struct {
	*tl.Entity
	Init int
	End  int
}

type GameOverZone

type GameOverZone struct {
	*tl.Entity
	EnteredZone bool
}

func CreateGameOverZone

func CreateGameOverZone(arena *Arena, hero *Hero) *GameOverZone

func (*GameOverZone) Collide

func (gameOverZone *GameOverZone) Collide(collision tl.Physical)

type Hero

type Hero struct {
	*tl.Entity
	Arena   *Arena
	Lasers  []*Laser
	IsAlive bool
}

func NewHero

func NewHero(arena *Arena) *Hero

func (*Hero) Collide

func (hero *Hero) Collide(collision tl.Physical)

func (*Hero) IsDead

func (hero *Hero) IsDead() bool

func (*Hero) Tick

func (hero *Hero) Tick(event tl.Event)

type Hud

type Hud struct {
	Title       string
	PressToQuit string
	Score       *tl.FpsText
}

func NewHud

func NewHud(arena *Arena, level *tl.BaseLevel) *Hud

func (*Hud) UpdateScore

func (hud *Hud) UpdateScore(score int)

type Invaders

type Invaders struct {
	*tl.Entity
	Game               *tl.Game
	Level              *tl.BaseLevel
	Arena              *Arena
	GameOverZone       *GameOverZone
	Hud                *Hud
	Hero               *Hero
	AlienCluster       *AlienCluster
	AlienLaserVelocity float64
	TimeDelta          float64
	RefreshSpeed       time.Duration
	Score              int
	Started            bool
	ScreenSizeNotOK    bool
}

func NewGame

func NewGame() *Invaders

func (*Invaders) RemoveDeadAliensAndIncrementScore

func (invaders *Invaders) RemoveDeadAliensAndIncrementScore()

func (*Invaders) Start

func (invaders *Invaders) Start()

func (*Invaders) Tick

func (invaders *Invaders) Tick(event tl.Event)

type Laser

type Laser struct {
	*tl.Rectangle
	Direction     int
	IsFromHero    bool
	IsNew         bool
	HasHit        bool
	HitAlienLaser bool
	Points        int
}

func NewAlienLaser

func NewAlienLaser(alienGunPosition int, y int) *Laser

func NewHeroLaser

func NewHeroLaser(heroGunPosition int, y int) *Laser

func (*Laser) Collide

func (laser *Laser) Collide(collision tl.Physical)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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