Documentation ¶
Index ¶
Constants ¶
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
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 ¶
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
type ObjectDimensions ¶
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