Removed extra variables
This commit is contained in:
parent
a3fa670c3d
commit
2fd97a7092
19
game.go
19
game.go
@ -87,7 +87,6 @@ type Game struct {
|
|||||||
stats GameStats
|
stats GameStats
|
||||||
mode GameMode
|
mode GameMode
|
||||||
bw *bandwidth.Bandwidth
|
bw *bandwidth.Bandwidth
|
||||||
Verbose bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GameMode interface {
|
type GameMode interface {
|
||||||
@ -294,7 +293,6 @@ func (g *Game) sendUpdate(payload *Boardstate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) run() {
|
func (g *Game) run() {
|
||||||
var t0, t1 time.Time
|
|
||||||
ticker := time.NewTicker(time.Duration(g.tick_duration) * time.Millisecond)
|
ticker := time.NewTicker(time.Duration(g.tick_duration) * time.Millisecond)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -327,17 +325,10 @@ func (g *Game) run() {
|
|||||||
delete(g.spectators, s)
|
delete(g.spectators, s)
|
||||||
close(s.send)
|
close(s.send)
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
t0 = time.Now()
|
|
||||||
payload := NewBoardstate()
|
payload := NewBoardstate()
|
||||||
|
|
||||||
g.turn++
|
g.turn++
|
||||||
payload.Turn = g.turn
|
payload.Turn = g.turn
|
||||||
if g.Verbose {
|
|
||||||
log.Printf("\033[2JTurn: %v", g.turn)
|
|
||||||
log.Printf("Players: %v", len(g.players))
|
|
||||||
log.Printf("Projectiles: %v", len(g.projectiles))
|
|
||||||
log.Printf("Explosions: %v", len(g.splosions))
|
|
||||||
}
|
|
||||||
|
|
||||||
// UPDATE GAME STATE
|
// UPDATE GAME STATE
|
||||||
if end, data := g.mode.gameOver(g); end {
|
if end, data := g.mode.gameOver(g); end {
|
||||||
@ -347,18 +338,8 @@ func (g *Game) run() {
|
|||||||
g.tick(payload)
|
g.tick(payload)
|
||||||
g.mode.tick(g, payload)
|
g.mode.tick(g, payload)
|
||||||
|
|
||||||
t1 = time.Now()
|
|
||||||
if g.Verbose {
|
|
||||||
log.Printf("Turn Processes %v\n", t1.Sub(t0))
|
|
||||||
}
|
|
||||||
|
|
||||||
// SEND THE UPDATE TO EACH PLAYER
|
// SEND THE UPDATE TO EACH PLAYER
|
||||||
g.sendUpdate(payload)
|
g.sendUpdate(payload)
|
||||||
|
|
||||||
t1 = time.Now()
|
|
||||||
if g.Verbose {
|
|
||||||
log.Printf("Sent Payload %v\n", t1.Sub(t0))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("run done")
|
log.Println("run done")
|
||||||
|
@ -72,7 +72,7 @@ func NewProtoTalker(id string, ws *websocket.Conn, bw *bandwidth.Bandwidth, enco
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pt *protoTalker) sender() {
|
func (pt *protoTalker) sender() {
|
||||||
log.Printf("%s: client launched", pt.Id)
|
log.Printf("%s: %T sender launched", pt.Id, pt.enc)
|
||||||
for things := range pt.send {
|
for things := range pt.send {
|
||||||
err := pt.enc.Encode(things)
|
err := pt.enc.Encode(things)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user