diff --git a/game/ai.go b/game/ai.go index 916d167..0c5507a 100644 --- a/game/ai.go +++ b/game/ai.go @@ -1,7 +1,5 @@ package game -import "log" - func chooseCommand(s State, teamID int) command { t := s.Teams[teamID] h := t.BatonHolder() @@ -23,7 +21,6 @@ func chooseCommand(s State, teamID int) command { if nextBot != nil { if h.Lane != nextBot.Lane { if abs(nextBot.Pos-h.Pos) < h.v { - log.Println("WHOOOOOOA") return slowDown } } diff --git a/gfx/gfx.go b/gfx/gfx.go index 5811c7f..aeac02f 100644 --- a/gfx/gfx.go +++ b/gfx/gfx.go @@ -2,7 +2,6 @@ package gfx import ( "image/color" - "log" "relay/game" "time" @@ -19,8 +18,6 @@ type RenderState struct { } func Render(rs RenderState, sOld, sNew game.State, w *pixelgl.Window, d time.Duration) RenderState { - // log.Printf("ENTER render sOld: %+v", sOld) - // log.Printf("ENTER render sNew: %+v", sNew) w.Clear(colornames.Peru) tween := float64(rs.Frame) / float64(rs.Frames) @@ -36,12 +33,10 @@ func Render(rs RenderState, sOld, sNew game.State, w *pixelgl.Window, d time.Dur return rs } -func renderBots(sOld, sNew game.State, tween float64, w *pixelgl.Window, d time.Duration, colors map[*game.Team]pixel.RGBA) { +func renderBots(sOld, sNew game.State, tween float64, w *pixelgl.Window, _ time.Duration, colors map[*game.Team]pixel.RGBA) { bounds := w.Bounds() im := imdraw.New(nil) - //log.Println("sOld.Teams:", sOld.Teams) - for i, t := range sNew.Teams { for j, bot := range t.Bots { c := colors[&sNew.Teams[i]] @@ -50,14 +45,9 @@ func renderBots(sOld, sNew game.State, tween float64, w *pixelgl.Window, d time. im.Color = c oldBot := sOld.Teams[i].Bots[j] - //log.Printf("oldBot: %+v", oldBot) - //log.Printf("newBot: %+v", bot) oldPos := lanePos(oldBot.Pos, oldBot.Lane, botWidth, bounds) newPos := lanePos(bot.Pos, bot.Lane, botWidth, bounds) - log.Println("oldPos:", oldPos) - log.Println("newPos:", newPos) - pos := pixel.Vec{ X: oldPos.X + tween*(newPos.X-oldPos.X), Y: oldPos.Y + tween*(newPos.Y-oldPos.Y), @@ -72,7 +62,6 @@ func renderBots(sOld, sNew game.State, tween float64, w *pixelgl.Window, d time. if t.Bots[j].ID == t.Baton.HolderID { renderBaton(pos, w) } - //log.Println("sOld.Teams[i].Bots[j]:", sOld.Teams[i].Bots[j]) } } } diff --git a/main.go b/main.go index ed3a144..76096c2 100644 --- a/main.go +++ b/main.go @@ -39,11 +39,15 @@ func run() { } switch { - case w.JustPressed(pixelgl.KeyQ): + case w.Pressed(pixelgl.KeyQ): return - case w.JustPressed(pixelgl.KeySpace): + case w.JustPressed(pixelgl.KeySpace) || true: rs.Animating = true s = game.UpdateState(s, sOld) + if s.GameOver { + s = game.NewState() + sOld = s + } } for rs.Animating { rs = gfx.Render(rs, sOld, s, w, time.Since(start))