Rendering updates
This commit is contained in:
parent
0a41558c72
commit
b113d52f66
|
@ -143,6 +143,7 @@ const (
|
||||||
Steps = 50
|
Steps = 50
|
||||||
numBots = 5
|
numBots = 5
|
||||||
NumTeams = 2
|
NumTeams = 2
|
||||||
|
NumLanes = 4
|
||||||
maxA = 3
|
maxA = 3
|
||||||
maxV = 10
|
maxV = 10
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,7 +23,10 @@ func renderBots(s game.State, w *pixelgl.Window, d time.Duration, colors map[*ga
|
||||||
|
|
||||||
for i, t := range s.Teams {
|
for i, t := range s.Teams {
|
||||||
for j, bot := range t.Bots {
|
for j, bot := range t.Bots {
|
||||||
im.Color = colors[&s.Teams[i]]
|
c := colors[&s.Teams[i]]
|
||||||
|
c.R += 0.2 * float64(j)
|
||||||
|
c.G -= 0.1 * float64(j)
|
||||||
|
im.Color = c
|
||||||
|
|
||||||
pos := lanePos(bot.Pos, bot.Lane, botWidth, bounds)
|
pos := lanePos(bot.Pos, bot.Lane, botWidth, bounds)
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ func renderBaton(pos pixel.Vec, w *pixelgl.Window) {
|
||||||
|
|
||||||
func lanePos(pos, lane int, width float64, bounds pixel.Rect) pixel.Vec {
|
func lanePos(pos, lane int, width float64, bounds pixel.Rect) pixel.Vec {
|
||||||
hOffset := bounds.Size().X / game.Steps
|
hOffset := bounds.Size().X / game.Steps
|
||||||
vOffset := bounds.Size().Y / (game.NumTeams + 1)
|
vOffset := bounds.Size().Y / (game.NumLanes + 1)
|
||||||
|
|
||||||
return pixel.V(bounds.Min.X+width/2+float64(pos)*hOffset,
|
return pixel.V(bounds.Min.X+width/2+float64(pos)*hOffset,
|
||||||
bounds.Min.Y+float64(lane+1)*vOffset)
|
bounds.Min.Y+float64(lane+1)*vOffset)
|
||||||
|
|
Loading…
Reference in New Issue