Skip to content

Commit df79807

Browse files
committed
Allow negative thrust
1 parent 9072218 commit df79807

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

events.cge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ event ready_players {
3131
// The `throttle` event allows you to change your throttle level and direction.
3232
// **NOTE:** These values are targets. The hovercraft needs some time to reach the desired values.
3333
event throttle {
34-
// Throttle level between 0-1.
34+
// Throttle level between -1 - 1.
3535
level: float,
3636
// The angle in degrees the hovercraft should be facing (up = 0°).
3737
angle: float

hoverrace/event_definitions.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ type ReadyPlayersEventData struct {
4242
}
4343

4444
// The `throttle` event allows you to change your throttle level and direction.
45-
// **NOTE:** This values are targets. The hovercraft needs some time to reach the desired values.
45+
// **NOTE:** These values are targets. The hovercraft needs some time to reach the desired values.
4646
const ThrottleEvent cg.EventName = "throttle"
4747

4848
type ThrottleEventData struct {
49-
// Throttle level between 0-1.
49+
// Throttle level between -1 - 1.
5050
Level float64 `json:"level"`
5151
// The angle in degrees the hovercraft should be facing (up = 0°).
5252
Angle float64 `json:"angle"`
@@ -87,8 +87,9 @@ type Hovercraft struct {
8787
}
8888

8989
// One unit equals the width of the hovercrafts and checkpoints.
90-
// The origin is in the bottom left corner.
9190
type Vec struct {
91+
// left to right
9292
X float64 `json:"x"`
93+
// bottom to top
9394
Y float64 `json:"y"`
9495
}

hoverrace/game.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ func (g *Game) handleThrottle(playerId string, event cg.Event) {
178178

179179
if data.Level > 1 {
180180
data.Level = 1
181-
} else if data.Level < 0 {
182-
data.Level = 0
181+
} else if data.Level < -1 {
182+
data.Level = -1
183183
}
184184

185185
player := g.players[playerId]

0 commit comments

Comments
 (0)