Version: v0.0.0-...-427eadb Latest Latest

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

Go to latest
Published: May 29, 2018 License: AGPL-3.0 Imports: 6 Imported by: 2




View Source
const (
	// PlaneSnapshotSize : uint8 (planeId) + float32 * 3 (location) + float32 * 4 (rotation) + 1 bit for firing + 7 bits damage
	PlaneSnapshotSize = 1 + 1 + (3 * 4) + (4 * 4)


This section is empty.


This section is empty.


type Bullet

type Bullet struct {
	// contains filtered or unexported fields

Bullet represent a bullet

func NewBullet

func NewBullet(source uint8, origin mathutils.Vector3D, direction *mathutils.Matrix3, speed float64, damage uint8) *Bullet

NewBullet create a new bullet

func (*Bullet) Update

func (b *Bullet) Update(deltaT float64) bool

Update updates the state of the bullet. Returns whether the bullet is still "living"

type Plane

type Plane struct {
	UID uint8
	// contains filtered or unexported fields

Plane describe a plane with all its properties

func NewPlane

func NewPlane(uid uint8, model PlaneModel, gun chan<- *Bullet) (plane *Plane)

NewPlane fill the plane with its default properties

func (*Plane) CorrectFromCollision

func (p *Plane) CorrectFromCollision(terrain *Terrain)

CorrectFromCollision update the position of the plane if there is a collision with the terrain

func (*Plane) Read

func (p *Plane) Read(snapshot []byte) (n int, err error)

func (*Plane) Update

func (p *Plane) Update(deltaT float64, terrain *Terrain)

Update updates the plane's properties from new parameters

func (*Plane) Write

func (p *Plane) Write(data []byte) (n int, err error)

type PlaneInput

type PlaneInput struct {
	Roll, Pitch, Yaw, Thrust float64
	IsFiring                 bool

PlaneInput ...

type PlaneModel

type PlaneModel struct {
	MaxThrust    float64            `json:"maxThrust"`
	Mass         float64            `json:"mass"`
	MaxRotations mathutils.Vector3D `json:"maxRotations"` // All in radians / seconds
	DragFactors  mathutils.Vector3D `json:"dragFactors"`  // A drag factor are "Area * Drag Coeficient * 0.5" of a side
	LiftMin      float64            `json:"liftMin"`
	LiftMax      float64            `json:"liftMax"`
	DefaultSpeed float64            `json:"defaultSpeed"` // Default speed of the plane on the Z axis
	Life         uint8              `json:"life"`

PlaneModel are all the constant properties that can easily be loaded from a JSON object

type PlayerInput

type PlayerInput struct {
	UID  uint8
	Data []byte

PlayerInput contains input data and the uid to which it is attributed

type Terrain

type Terrain struct {
	// contains filtered or unexported fields

Terrain ...

func LoadTerrain

func LoadTerrain(filePath string) (*Terrain, error)

LoadTerrain loads the terrain

func (*Terrain) OverredTriangle

func (t *Terrain) OverredTriangle(pos mathutils.Vector3D) (s [3]mathutils.Vector3D)

OverredTriangle find the triangle that is overred by the vector pos. Return a triangle made of 3 Vector3D

type World

type World struct {
	Input     chan PlayerInput
	Snapshots chan []byte

	End chan bool // End the world
	// contains filtered or unexported fields

World World is which everything happens

func NewWorld

func NewWorld(terrain *Terrain) *World

NewWorld Creates a new world

func (*World) Join

func (w *World) Join(uid uint8, model PlaneModel)

Join ...

func (*World) Leave

func (w *World) Leave(uid uint8)

Leave ...

func (*World) Run

func (w *World) Run(simulationInterval time.Duration, snapshotInterval time.Duration)

Run starts and run the world

Jump to

Keyboard shortcuts

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