player

package
v0.0.0-...-56dc94b Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	Register   chan *Player
	Unregister chan uint32 // Player IDS sent to this channel will be deleted from the players map
	// contains filtered or unexported fields
}

Manager tracks the player data.

func CreateManager

func CreateManager() *Manager

CreateManager will create and return a Manager instance

func (*Manager) Run

func (m *Manager) Run(server *ws.Server)

Run will select on the Manager channels in an endless loop.

type Player

type Player struct {
	ID          uint32        `json:"id"`
	Name        string        `json:"name"`
	Position    vector.Vector `json:"position"`
	Destination vector.Vector `json:"-"` // The position that the player is moving towards.
}

Player is used to hold player data.

func (*Player) MoveToDest

func (p *Player) MoveToDest()

MoveToDest will move the player towards the destination.

func (*Player) Pos

func (p *Player) Pos() []byte

Pos will return the player position as a byte slice. The player ID is included at the start of the slice.

Jump to

Keyboard shortcuts

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