From e31c585e3af4c80a3333ce4cc9c6fd20129c5acb Mon Sep 17 00:00:00 2001 From: Luke Meyers Date: Fri, 7 Feb 2020 22:19:34 -0800 Subject: [PATCH] tweaks --- game/commands.go | 2 ++ game/game.go | 4 ++-- game/physics.go | 22 +++++++++++----------- gfx/gfx.go | 12 ++++++++---- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/game/commands.go b/game/commands.go index 64b8b55..c001cd7 100644 --- a/game/commands.go +++ b/game/commands.go @@ -40,6 +40,8 @@ func doCommand(cmd command, s State, teamID int) State { pos := b.Position pos.Pos++ s = removeObstacle(s, pos) + b.v = 0 + s = updateBot(s, *b) } if b := ActiveBot(s.Teams[teamID]); b != nil { diff --git a/game/game.go b/game/game.go index 0dd03fe..dcbd2fc 100644 --- a/game/game.go +++ b/game/game.go @@ -33,7 +33,7 @@ func maybePassBaton(s State, teamID int) State { if h.ID >= b.ID || h.Position.Lane != b.Position.Lane { continue } - if abs(b.Position.Pos-h.Position.Pos) <= passDistance { + if abs(b.Position.Pos-h.Position.Pos) <= PassDistance { h.v = 0 h.a = 0 s = updateBot(s, *h) @@ -259,6 +259,6 @@ var ( const ( Steps = 40 numBots = 4 - NumTeams = 4 + NumTeams = 2 NumLanes = NumTeams ) diff --git a/game/physics.go b/game/physics.go index 0213bfe..43d7d4b 100644 --- a/game/physics.go +++ b/game/physics.go @@ -1,19 +1,19 @@ package game func accelerate(b Bot) Bot { - if b.a < -maxA { - b.a = -maxA + if b.a < -MaxA { + b.a = -MaxA } - if b.a > maxA { - b.a = maxA + if b.a > MaxA { + b.a = MaxA } b.v += b.a - if b.v > maxV { - b.v = maxV + if b.v > MaxV { + b.v = MaxV } - if b.v < -maxV { - b.v = -maxV + if b.v < -MaxV { + b.v = -MaxV } return b @@ -50,7 +50,7 @@ func collide(pos, lane int, s State) interface{} { const ( baseAccel = 1 - maxA = 1 - maxV = 2 - passDistance = 2 + MaxA = 1 + MaxV = 2 + PassDistance = 2 ) diff --git a/gfx/gfx.go b/gfx/gfx.go index 1625966..83b6d89 100644 --- a/gfx/gfx.go +++ b/gfx/gfx.go @@ -109,13 +109,17 @@ func teamColors(ts []game.Team) map[*game.Team]pixel.RGBA { var c color.RGBA switch i { case 0: - c = colornames.Cyan + c = colornames.Red case 1: - c = colornames.Gold + c = colornames.Green case 2: - c = colornames.Lavender + c = colornames.Blue case 3: - c = colornames.Rosybrown + c = colornames.Magenta + case 4: + c = colornames.Cyan + case 5: + c = colornames.Yellow } m[&ts[i]] = pixel.ToRGBA(c) }