diff options
author | Jared Folkins <jfolkins@gmail.com> | 2016-03-08 17:52:36 -0800 |
---|---|---|
committer | Jared Folkins <jfolkins@gmail.com> | 2016-03-08 17:52:36 -0800 |
commit | 4f460ef4a040ae0f144660ef2aceb469de196510 (patch) | |
tree | 9010a66f95a726b22aea7ab34608ebd747738cc5 | |
parent | ed88747493d14cfe1841a21eb22908b3d3dd9b17 (diff) | |
download | sshtron-4f460ef4a040ae0f144660ef2aceb469de196510.tar.gz |
enhc: prevent player from immediately reversing into their own trail
-rw-r--r-- | game.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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() |