diff --git a/game/ai.go b/game/ai.go index 0c5507a..6f7a045 100644 --- a/game/ai.go +++ b/game/ai.go @@ -4,7 +4,7 @@ func chooseCommand(s State, teamID int) command { t := s.Teams[teamID] h := t.BatonHolder() if collide(h.Pos+1, h.Lane, s) { - if h.Lane <= t.Lane { + if h.Lane <= t.Lane && h.Lane < NumLanes-1 { return left } return right diff --git a/game/game.go b/game/game.go index c94bc0b..6d9ce54 100644 --- a/game/game.go +++ b/game/game.go @@ -188,7 +188,7 @@ const ( Steps = 60 numBots = 5 NumTeams = 4 - NumLanes = 6 + NumLanes = 4 maxA = 2 maxV = 8 ) diff --git a/gfx/gfx.go b/gfx/gfx.go index aeac02f..ee60c96 100644 --- a/gfx/gfx.go +++ b/gfx/gfx.go @@ -27,7 +27,7 @@ func Render(rs RenderState, sOld, sNew game.State, w *pixelgl.Window, d time.Dur renderObstacles(sNew, w) rs.Frame++ - if rs.Frame >= rs.Frames { + if rs.Frame > rs.Frames { rs.Animating = false } return rs @@ -40,8 +40,6 @@ func renderBots(sOld, sNew game.State, tween float64, w *pixelgl.Window, _ time. for i, t := range sNew.Teams { for j, bot := range t.Bots { c := colors[&sNew.Teams[i]] - c.R += 0.2 * float64(j) - c.G -= 0.1 * float64(j) im.Color = c oldBot := sOld.Teams[i].Bots[j] @@ -113,7 +111,7 @@ func teamColors(ts []game.Team) map[*game.Team]pixel.RGBA { case 2: c = colornames.Lavender case 3: - c = colornames.Indigo + c = colornames.Maroon } m[&ts[i]] = pixel.ToRGBA(c) } diff --git a/main.go b/main.go index 5b1c53c..e31f5d2 100644 --- a/main.go +++ b/main.go @@ -35,7 +35,6 @@ func run() { Animating: false, Frames: 20, } - sOld := s for !w.Closed() && !s.GameOver { @@ -47,7 +46,7 @@ func run() { if !rs.Animating { sOld = s } - default: + case w.Pressed(pixelgl.KeySpace): rs.Animating = true rs.Frame = 0 s = game.UpdateState(s, sOld)