Documentation ¶
Index ¶
- Constants
- func AngleDifference(a, b float64) float64
- func NormalizeAngle(degrees float64) float64
- func ToDegrees(radians float64) float64
- func ToRadians(degrees float64) float64
- type CheckpointsEventData
- type ControlCmdData
- type CountdownEventData
- type FinishedPlayer
- type FinishedPlayersEventData
- type Game
- type GameConfig
- type Hovercraft
- type HovercraftsEventData
- type InProgressEventData
- type Player
- type RaceOverEventData
- type ReadyCmdData
- type ReadyPlayersEventData
- type StartEventData
- type Vec
Constants ¶
const CheckpointsEvent cg.EventName = "checkpoints"
The `checkpoints` event contains all of the remaining checkpoints.
const ControlCmd cg.CommandName = "control"
The `control` command allows you to change your throttle level and direction. **NOTE:** These values are targets. The hovercraft needs some time to reach the desired values.
const CountdownEvent cg.EventName = "countdown"
The `countdown` counts down from 5. When the value reaches 0 a `start` event will be sent instead of the `countdown` event.
const FinishedPlayersEvent cg.EventName = "finished_players"
The `finished_players` event contains a list of players that have finished the race.
const HovercraftsEvent cg.EventName = "hovercrafts"
The `hovercraft` event tells all clients where all the hovercrafts are and how they are moving.
const InProgressEvent cg.EventName = "in_progress"
The `in_progress` event is sent to sockets which connect to the game while it's running.
const RaceOverEvent cg.EventName = "race_over"
The `race_over` event is sent when all players finished the game or the time runs out.
const ReadyCmd cg.CommandName = "ready"
Send the `ready` command to the server when you think the game should begin.
const ReadyPlayersEvent cg.EventName = "ready_players"
The `ready_players` event contains a list of all players which are ready.
const StartEvent cg.EventName = "start"
The `start` event is sent when the race begins. The game begins once at least 2 players have joined and all players have sent the `ready` event.
Variables ¶
This section is empty.
Functions ¶
func AngleDifference ¶
func NormalizeAngle ¶
Types ¶
type CheckpointsEventData ¶
type ControlCmdData ¶
type CountdownEventData ¶
type CountdownEventData struct { // The current value of the countdown (5-1). Value int `json:"value"` }
type FinishedPlayer ¶
type FinishedPlayer struct { // The ID of the player. Id string `json:"id"` // The place, the player has reached. Place int `json:"place"` // The amount of time in milliseconds the player needed to finish the race. Duration int64 `json:"duration"` }
`finished_player` represents an entry in the final ranking.
type FinishedPlayersEventData ¶
type FinishedPlayersEventData struct { // A list of players that have finished the race sorted by their placement. Players []FinishedPlayer `json:"players"` }
type GameConfig ¶
type GameConfig struct { // The speed at which the thrust level reacts to user input. default = 1 ThrottleSpeed float64 `json:"throttle_speed"` // The speed at which hovercrafts turn. default = 220 TurnSpeed float64 `json:"turn_speed"` // The maximum acceleration of hovercrafts. default = 5 MaxAcceleration float64 `json:"max_acceleration"` // The maximum velocity of hovercrafts. default = 20 MaxVelocity float64 `json:"max_velocity"` // The amount of checkpoints per game. default = 10 CheckpointCount int `json:"checkpoint_count"` // The time in seconds that a game is allowed to last. default = infinite Timeout int `json:"timeout"` }
type Hovercraft ¶
type Hovercraft struct { // The position of the center of the hovercraft. Pos Vec `json:"pos"` // The current velocity of the hovercraft. Velocity Vec `json:"velocity"` // The current thrust level of the hovercraft. Thrust float64 `json:"thrust"` // The angle in degrees the hovercraft is facing (right = 0°, up = 90°, left = 180°, down = -90°). Angle float64 `json:"angle"` // The amount of reached checkpoints. Checkpoints int `json:"checkpoints"` }
A hovercraft is a circle with a diameter of 1 unit.
type HovercraftsEventData ¶
type HovercraftsEventData struct { // All hovercrafts mapped to their respective player IDs. Hovercrafts map[string]Hovercraft `json:"hovercrafts"` // The time in UNIX milliseconds when this event occured. Time int64 `json:"time"` }
type InProgressEventData ¶
type InProgressEventData struct { }
type RaceOverEventData ¶
type RaceOverEventData struct { // The players that have finished the game before the time ran out. FinishedPlayers []FinishedPlayer `json:"finished_players"` // The IDs of the players that have not finished the game before the time ran out. UnfinishedPlayers []string `json:"unfinished_players"` }
type ReadyCmdData ¶
type ReadyCmdData struct { }
type ReadyPlayersEventData ¶
type StartEventData ¶
type StartEventData struct { }
type Vec ¶
One unit equals the width of the hovercrafts and checkpoints.