aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--game.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/game.go b/game.go
index 18c10fd..f51b726 100644
--- a/game.go
+++ b/game.go
@@ -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 {
Un proyecto texto-plano.xyz