diff options
Diffstat (limited to 'game.go')
-rw-r--r-- | game.go | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -4,13 +4,14 @@ import ( "bufio" "bytes" "fmt" - "github.com/dustinkirkland/golang-petname" - "github.com/fatih/color" - "golang.org/x/crypto/ssh" "io" "math/rand" "sort" "time" + + "github.com/dustinkirkland/golang-petname" + "github.com/fatih/color" + "golang.org/x/crypto/ssh" ) type Hub struct { @@ -177,26 +178,39 @@ func (p *Player) calculateScore(delta float64, playerCount int) float64 { } func (p *Player) HandleUp() { + if p.Direction == PlayerDown { + return + } p.Direction = PlayerUp p.Marker = playerUpRune p.s.didAction() } func (p *Player) HandleLeft() { + if p.Direction == PlayerRight { + return + } p.Direction = PlayerLeft p.Marker = playerLeftRune p.s.didAction() } func (p *Player) HandleDown() { + if p.Direction == PlayerUp { + return + } p.Direction = PlayerDown p.Marker = playerDownRune p.s.didAction() } func (p *Player) HandleRight() { + if p.Direction == PlayerLeft { + return + } p.Direction = PlayerRight p.Marker = playerRightRune + p.s.didAction() } func (p *Player) Score() int { |