core

package
v0.0.0-...-65b0265 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2017 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PlayerShipWidth  float32 = 64.0
	PlayerShipHeight float32 = 64.0
	AmmoWidth        float32 = 10.0
	AmmoHeight       float32 = 14.0
	EnemyWidth       float32 = 40.0
	EnemyHeight      float32 = 40.0
)

constants for how big are objects

View Source
const (
	WorldWidth  = 800.0
	WorldHeight = 640.0
)

constants for how big is the world

Variables

This section is empty.

Functions

This section is empty.

Types

type GameObjectType

type GameObjectType int

GameObjectType is enum type for the type of the object

const (
	// PlayerShip player controller ships
	PlayerShip GameObjectType = iota
	// EnemyShip enemy ships
	EnemyShip
	// PlayerAmmo weapon ammonutions from player
	PlayerAmmo
	// EnemyAmmo weapon ammonutions from enemy
	EnemyAmmo
)

type GameObjectUpdate

type GameObjectUpdate struct {
	Type GameObjectType
	ID   uint64
}

GameObjectUpdate Type used for keeping track of new and deleted objects

type GameWorld

type GameWorld struct {
	PlayerShips []Spaceship
	PlayerAmmos []Projectile

	EnemyShips []Spaceship
	EnemyAmmos []Projectile

	NewGameObjects     []GameObjectUpdate
	DeletedGameObjects []GameObjectUpdate

	PlayerScore int
	// contains filtered or unexported fields
}

GameWorld the game world keeping track of all game objects and updating them

func NewGameWorld

func NewGameWorld() GameWorld

NewGameWorld Creates and intializes new game world

func (*GameWorld) AddNewPlayer

func (world *GameWorld) AddNewPlayer() (id uint64)

AddNewPlayer adds new player to the world and returns the id of the player spaceship

func (*GameWorld) ClearUpdates

func (world *GameWorld) ClearUpdates()

ClearUpdates Clears arrays keeping track of new and deleted objects

func (*GameWorld) Start

func (world *GameWorld) Start()

Start starts the game

func (*GameWorld) Stop

func (world *GameWorld) Stop()

Stop stops and cleans up the game

func (*GameWorld) Update

func (world *GameWorld) Update(dirs map[uint64]SpaceshipDirection, delta float32)

Update updates the game world it receives array of directions which the player spaceship took and updates every object positions

type ObjectDimensions

type ObjectDimensions struct {
	ID   uint64
	X, Y float32
	// contains filtered or unexported fields
}

ObjectDimensions is common struct for all game objects which needs position and size

type Projectile

type Projectile struct {
	ObjectDimensions

	Type GameObjectType
	// contains filtered or unexported fields
}

Projectile is ammo created by the ships

type Spaceship

type Spaceship struct {
	ObjectDimensions
}

Spaceship is basic data for an enitty in the game

type SpaceshipDirection

type SpaceshipDirection int

SpaceshipDirection enum type for the direction of the player spaceship

const (
	Still SpaceshipDirection = iota
	Up
	Down
	Left
	Right
	UpRight
	UpLeft
	DownRight
	DownLeft
)

Enum types for different directions

Jump to

Keyboard shortcuts

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