@@ -3,7 +3,7 @@ package hoverrace
33import "github.com/code-game-project/go-server/cg"
44
55type GameConfig struct {
6- // The speed at which the throttle reacts to user input. default = 1
6+ // The speed at which the thrust level reacts to user input. default = 1
77 ThrottleSpeed float64 `json:"throttle_speed"`
88 // The speed at which hovercrafts turn. default = 220
99 TurnSpeed float64 `json:"turn_speed"`
@@ -13,34 +13,39 @@ type GameConfig struct {
1313 MaxVelocity float64 `json:"max_velocity"`
1414 // The amount of checkpoints per game. default = 10
1515 CheckpointCount int `json:"checkpoint_count"`
16+ // The time in milliseconds that a game is allowed to last. default = infinite
17+ Timeout int `json:"timeout"`
1618}
1719
1820// Send the `ready` command to the server when you think the game should begin.
1921const ReadyCmd cg.CommandName = "ready"
2022
21- type ReadyCmdData struct {}
23+ type ReadyCmdData struct {
24+ }
2225
23- // The `throttle ` command allows you to change your throttle level and direction.
26+ // The `control ` command allows you to change your throttle level and direction.
2427// **NOTE:** These values are targets. The hovercraft needs some time to reach the desired values.
25- const ThrottleCmd cg.CommandName = "throttle "
28+ const ControlCmd cg.CommandName = "control "
2629
27- type ThrottleCmdData struct {
28- // Throttle level between -1 - 1.
29- Level float64 `json:"level "`
30- // The angle in degrees the hovercraft should be facing (up = 0°).
30+ type ControlCmdData struct {
31+ // Thrust level between -1 and 1.
32+ Thrust float64 `json:"thrust "`
33+ // The angle in degrees the hovercraft should be facing (right = 0°).
3134 Angle float64 `json:"angle"`
3235}
3336
3437// The `start` event is sent when the race begins.
3538// The game begins once at least 2 players have joined and all players have sent the `ready` event.
3639const StartEvent cg.EventName = "start"
3740
38- type StartEventData struct {}
41+ type StartEventData struct {
42+ }
3943
4044// The `in_progress` event is sent to sockets which connect to the game while it's running.
4145const InProgressEvent cg.EventName = "in_progress"
4246
43- type InProgressEventData struct {}
47+ type InProgressEventData struct {
48+ }
4449
4550// The `countdown` counts down from 5. When the value reaches 0 a `start` event will be sent instead of the `countdown` event.
4651const CountdownEvent cg.EventName = "countdown"
@@ -88,14 +93,24 @@ type FinishedPlayersEventData struct {
8893 Players []FinishedPlayer `json:"players"`
8994}
9095
96+ // The `game_over` event is sent when all players finished the game or the time runs out.
97+ const GameOverEvent cg.EventName = "game_over"
98+
99+ type GameOverEventData struct {
100+ // The players that have finished the game before the time ran out.
101+ FinishedPlayers []FinishedPlayer `json:"finished_players"`
102+ // The IDs of the players that have not finished the game before the time ran out.
103+ UnfinishedPlayers []string `json:"unfinished_players"`
104+ }
105+
91106// A hovercraft is a circle with a diameter of 1 unit.
92107type Hovercraft struct {
93108 // The position of the center of the hovercraft.
94109 Pos Vec `json:"pos"`
95110 // The current velocity of the hovercraft.
96111 Velocity Vec `json:"velocity"`
97- // The current throttle of the hovercraft.
98- Throttle float64 `json:"throttle "`
112+ // The current thrust level of the hovercraft.
113+ Thrust float64 `json:"thrust "`
99114 // The angle in degrees the hovercraft is facing (up = 0°).
100115 Angle float64 `json:"angle"`
101116 // The amount of reached checkpoints.
0 commit comments