Back to godoc.org

Package plancom

v0.0.0-...-5d5f7ec
Latest Go to latest

The latest major version is .

Published: Feb 4, 2020 | License: GPL3 | Module: github.com/atolVerderben/planetcommand

Index

Constants

const (
	MissileLauncherLeft   = "LeftLauncher"
	MissileLauncherRight  = "RightLauncher"
	MissileLauncherTop    = "TopLauncher"
	MissileLauncherBottom = "BottomLauncher"
)

These specifiy the edge of the screen MissileLauncher names/positions

Variables

var (
	Cannon1 = "CANNON A" //"ACAPULCO"
	Cannon2 = "CANNON B" //"BEIJING"
	Cannon3 = "CANNON C" //"COLOGNE"
	Cannon4 = "CANNON D" //"DALLAS"
)

Names of the Cannons for UI purposes

var (
	//ScreenWidth of the game
	ScreenWidth float64
	//ScreenHeight of the game
	ScreenHeight float64
	//FntMain is Kanit font
	FntMain = "FntKanit"
	//AngleDrawOffset is 90 degrees (All images in spritesheet face UP... Right is 0 degrees/radians)
	AngleDrawOffset = 1.5708
	//SpriteSheets hold all the spritesheets for the game
	SpriteSheets = map[string]*tentsuyu.SpriteSheet{}
)
var (
	GameStateMsgMain  tentsuyu.GameStateMsg = "MainGame"
	GameStateMsgTitle tentsuyu.GameStateMsg = "Game Title Screen"
)

GameState Messages used for this game

var Game *tentsuyu.Game

Game is the tentsuyu.Game which contains all the relevant library attributes

func NewGame

func NewGame(w, h float64) (game *tentsuyu.Game, err error)

NewGame returns a new Game while setting the width and height of the screen

type AI

type AI interface{}

AI will represent the artificial intelligence of the game

type AIController

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

AIController controls all the AI elements for the game

func CreateAIController

func CreateAIController() *AIController

CreateAIController returns a new AIController

func (*AIController) Update

func (a *AIController) Update(p *Planet)

Update the AIController. This will coordinate all different AI Types

type AILauncher

type AILauncher struct {
	*MissileLauncher
	// contains filtered or unexported fields
}

AILauncher controls the various missile launchers

func CreateAILauncher

func CreateAILauncher(name string) *AILauncher

CreateAILauncher returns a new AILauncher

func CreateEdgeAILaunchers

func CreateEdgeAILaunchers() []*AILauncher

CreateEdgeAILaunchers is a convenient function to return the 4 edge launchers

func (*AILauncher) LaunchMissile

func (a *AILauncher) LaunchMissile(tx, ty float64)

LaunchMissile at the provided target x,y coords

func (*AILauncher) Update

func (a *AILauncher) Update(planet *Planet)

Update the AILauncher and determine when to fire new missiles

type AIUfo

type AIUfo struct {
	*tentsuyu.BasicObject
	Health      int
	Destination *tentsuyu.Vector2d
	// contains filtered or unexported fields
}

AIUfo controls the ufo that attacks the player planet

func SpawnUFO

func SpawnUFO(x, y float64) *AIUfo

SpawnUFO at the provided coords

func (*AIUfo) Draw

func (u *AIUfo) Draw(screen *ebiten.Image) error

Draw the ufo

func (*AIUfo) Hit

func (u *AIUfo) Hit() bool

Hit updates the UFO to a hit state. Returns true if ufo was not in invulnerable state, otherwise returns false

func (AIUfo) IsAlive

func (u AIUfo) IsAlive() bool

IsAlive returns true if UFO health is greater than 0

func (AIUfo) IsDead

func (u AIUfo) IsDead() bool

IsDead returns true if the UFO has no more health

func (*AIUfo) Update

func (u *AIUfo) Update(p *Planet, playArea *tentsuyu.Rectangle)

Update the AIUfo

type Cannon

type Cannon struct {
	*tentsuyu.BasicObject
	Name string

	Health int
	// contains filtered or unexported fields
}

Cannon is the player's way of attacking incoming threats

func CreateCannon

func CreateCannon(planet *Planet, angle float64, name string) *Cannon

CreateCannon returns a Cannon on the given planet at the starting angle (position on planet)

func (*Cannon) AddCommand

func (c *Cannon) AddCommand(command Command)

AddCommand to command queue

func (Cannon) Draw

func (c Cannon) Draw(screen *ebiten.Image) error

Draw the Cannon and the view cone

func (Cannon) DrawRays

func (c Cannon) DrawRays(screen *ebiten.Image)

DrawRays draws the "view cone" for the cannon

func (*Cannon) FireMissile

func (c *Cannon) FireMissile(tx, ty float64) bool

FireMissile returns true if the cannon is able to fire and creates a new missile

func (*Cannon) Hit

func (c *Cannon) Hit()

Hit reduces the cannon's hp if it's not cooling down. The cooldown period prevents instant death

func (*Cannon) InFireRadius

func (c *Cannon) InFireRadius(x, y float64) bool

InFireRadius returns true if the given coords are within the cannon's "firing cone"

func (Cannon) IsAlive

func (c Cannon) IsAlive() bool

IsAlive returns true if cannon health is greater than 0

func (*Cannon) RemoveMissile

func (c *Cannon) RemoveMissile(missileID string)

RemoveMissile from the cannon's slice

func (*Cannon) ShiftCommand

func (c *Cannon) ShiftCommand() Command

ShiftCommand removes the first element from the command queue and returns it.

func (*Cannon) Update

func (c *Cannon) Update(planet *Planet)

Update the cannon

type Command

type Command int

Command is an integer that tells the cannons what to do

const (
	CommandNone Command = iota
	CommandLeft
	CommandRight
)

List of available Commands

type Explosion

type Explosion struct {
	*tentsuyu.BasicObject
	// contains filtered or unexported fields
}

Explosion is generated when a missile hits its target or reaches its destination

func CreateExplosion

func CreateExplosion(x, y float64, givePoints bool) *Explosion

CreateExplosion at given coords

func (*Explosion) Draw

func (e *Explosion) Draw(screen *ebiten.Image) error

Draw the explosion

func (*Explosion) Update

func (e *Explosion) Update()

Update explosion

type GameMain

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

GameMain represents the main GameState of our game

func NewGameMain

func NewGameMain(game *tentsuyu.Game) *GameMain

NewGameMain returns our main gamestate

func (*GameMain) Draw

func (g *GameMain) Draw(game *tentsuyu.Game) error

Draw the gamestate scene

func (GameMain) Msg

func (g GameMain) Msg() tentsuyu.GameStateMsg

Msg returns the gamestatemsg and achieves the GameState interface

func (*GameMain) RemoveExplosion

func (g *GameMain) RemoveExplosion(exID string)

RemoveExplosion from the game

func (*GameMain) RemoveUFO

func (g *GameMain) RemoveUFO(exID string)

RemoveUFO from the game

func (*GameMain) SetMsg

func (g *GameMain) SetMsg(gs tentsuyu.GameStateMsg)

SetMsg sets the gamestatemsg value

func (*GameMain) SetOverlay

func (g *GameMain) SetOverlay(text []string, displayTime int, offsetX, offsetY float64, clickToContinue bool)

SetOverlay sets the text to display, the duration, the offeset of X,Y and if the text can be skipped by clicking

func (*GameMain) StepZoom

func (g *GameMain) StepZoom(camera *tentsuyu.Camera, zoomOut bool)

StepZoom increments set zoom levels. Helps keep the game looking good at chosen levels

func (*GameMain) Update

func (g *GameMain) Update(game *tentsuyu.Game) error

Update the gamestate

type Missile

type Missile struct {
	*tentsuyu.BasicObject
	OriginX, OriginY float64
	TargetX, TargetY float64
	Velocity         *tentsuyu.Vector2d
	Active           bool
	// contains filtered or unexported fields
}

Missile is the main projectile of the game

func CreateMissile

func CreateMissile(x, y, tx, ty, speed float64, color string) *Missile

CreateMissile returns a new Missile at the specified x,y coords with the target tx,ty

func (*Missile) Draw

func (m *Missile) Draw(screen *ebiten.Image) error

Draw the missile

func (*Missile) DrawTrail

func (m *Missile) DrawTrail(screen *ebiten.Image)

DrawTrail of the Missile. This is separate so that it can be drawn at a different level

func (*Missile) Update

func (m *Missile) Update()

Update the missile

type MissileLauncher

type MissileLauncher struct {
	*tentsuyu.BasicObject
	Name string
	// contains filtered or unexported fields
}

MissileLauncher launches missiles

func CreateConstantMissileLauncher

func CreateConstantMissileLauncher(name string) *MissileLauncher

CreateConstantMissileLauncher creates one of the 4 just off screen Missile Launchers that constantly launch missiles at our player

func CreateMissileLauncher

func CreateMissileLauncher(x, y float64, width, height int, name string) *MissileLauncher

CreateMissileLauncher creates a MissileLauncher, which launches Missiles

func (*MissileLauncher) RemoveMissile

func (m *MissileLauncher) RemoveMissile(missileID string)

RemoveMissile from the launcher's slice

type Orbiter

type Orbiter struct {
	*tentsuyu.BasicObject
	// contains filtered or unexported fields
}

Orbiter is an object designed to orbit a planet

func NewOrbiter

func NewOrbiter(x, y float64, w, h int, orbitObject tentsuyu.GameObject, distance float64) *Orbiter

NewOrbiter creates a new orbiter object

func (*Orbiter) Update

func (o *Orbiter) Update()

Update the orbiter

type Planet

type Planet struct {
	*tentsuyu.BasicObject
	Health int
}

Planet is what the player must protect

func CreatePlanet

func CreatePlanet(x, y float64, w, h int) *Planet

CreatePlanet at given coords with given width and height

func (Planet) GetRadius

func (p Planet) GetRadius() float64

GetRadius returns the radius of the planet (i.e. width/2)

func (Planet) IsAlive

func (p Planet) IsAlive() bool

IsAlive returns true if the planet has health above 0

type Projectile

type Projectile interface {
	Draw(*ebiten.Image) error
	DrawTrail(*ebiten.Image)
	Update()
}

Projectile is the generic

type ScoreEntry

type ScoreEntry struct {
	Entry1, Entry2, Entry3         int
	Text1, Text2, Text3, TitleText *tentsuyu.TextElement
	CurrSelection                  int
	StartX, StartY                 float64
	Confirmed                      bool
	// contains filtered or unexported fields
}

ScoreEntry updates and displays the entry screen for entering the initials for the high score screen

func NewScoreEntry

func NewScoreEntry(x, y float64) *ScoreEntry

NewScoreEntry returns a new ScoreEntry at the given x,y coords

func (*ScoreEntry) Draw

func (s *ScoreEntry) Draw(screen *ebiten.Image) error

Draw the score Entry

func (ScoreEntry) ToString

func (s ScoreEntry) ToString() string

ToString returns the score entry 3 values as a single string

func (*ScoreEntry) Update

func (s *ScoreEntry) Update(input *tentsuyu.InputController)

Update the ScoreEntry. Up and Down change the selected letter space either up or down the alphabet. Left and Right change which letter space is selected. Enter confirms the entry to a high score.

type TitleScreen

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

TitleScreen represents the main GameState of our game

func NewTitleScreen

func NewTitleScreen(game *tentsuyu.Game) *TitleScreen

NewTitleScreen returns our main gamestate

func (*TitleScreen) Draw

func (g *TitleScreen) Draw(game *tentsuyu.Game) error

Draw the gamestate scene

func (TitleScreen) Msg

func (g TitleScreen) Msg() tentsuyu.GameStateMsg

Msg returns the gamestatemsg and achieves the GameState interface

func (*TitleScreen) SetMsg

func (g *TitleScreen) SetMsg(gs tentsuyu.GameStateMsg)

SetMsg sets the gamestatemsg value

func (*TitleScreen) Update

func (g *TitleScreen) Update(game *tentsuyu.Game) error

Update the gamestate

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier