add coast command
This commit is contained in:
parent
70600a1142
commit
e80f51a700
|
@ -7,14 +7,15 @@ import (
|
||||||
type Command int
|
type Command int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
speedUp Command = iota
|
coast Command = iota
|
||||||
|
speedUp
|
||||||
slowDown
|
slowDown
|
||||||
left
|
left
|
||||||
right
|
right
|
||||||
clearObstacle
|
clearObstacle
|
||||||
)
|
)
|
||||||
|
|
||||||
var validCommands = []Command{speedUp, slowDown, left, right, clearObstacle}
|
var validCommands = []Command{coast, speedUp, slowDown, left, right, clearObstacle}
|
||||||
|
|
||||||
func PollCommands(s State) []Command {
|
func PollCommands(s State) []Command {
|
||||||
cmds := make([]Command, len(s.Teams))
|
cmds := make([]Command, len(s.Teams))
|
||||||
|
@ -36,6 +37,7 @@ func doCommand(cmd Command, s State, teamID int) State {
|
||||||
r.Kinetics.A = 0
|
r.Kinetics.A = 0
|
||||||
|
|
||||||
switch cmd {
|
switch cmd {
|
||||||
|
case coast:
|
||||||
case speedUp:
|
case speedUp:
|
||||||
r.Kinetics.A = da
|
r.Kinetics.A = da
|
||||||
*r = accelerate(*r)
|
*r = accelerate(*r)
|
||||||
|
@ -68,6 +70,8 @@ func doCommand(cmd Command, s State, teamID int) State {
|
||||||
|
|
||||||
func (c Command) String() string {
|
func (c Command) String() string {
|
||||||
switch c {
|
switch c {
|
||||||
|
case coast:
|
||||||
|
return "coast"
|
||||||
case speedUp:
|
case speedUp:
|
||||||
return "speed up"
|
return "speed up"
|
||||||
case slowDown:
|
case slowDown:
|
||||||
|
|
Loading…
Reference in New Issue