aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Folkins <jfolkins@gmail.com>2016-03-08 17:52:36 -0800
committerJared Folkins <jfolkins@gmail.com>2016-03-08 17:52:36 -0800
commit4f460ef4a040ae0f144660ef2aceb469de196510 (patch)
tree9010a66f95a726b22aea7ab34608ebd747738cc5
parented88747493d14cfe1841a21eb22908b3d3dd9b17 (diff)
downloadsshtron-4f460ef4a040ae0f144660ef2aceb469de196510.tar.gz
enhc: prevent player from immediately reversing into their own trail
-rw-r--r--game.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/game.go b/game.go
index 209b776..f51b726 100644
--- a/game.go
+++ b/game.go
@@ -178,24 +178,36 @@ 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()
Un proyecto texto-plano.xyz