From ae0256ca89a9adfc1a06edc88a8bcfe8a37b61bf Mon Sep 17 00:00:00 2001 From: Luke Meyers Date: Sat, 8 Feb 2020 19:28:39 -0800 Subject: [PATCH] batch baton --- gfx/gfx.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gfx/gfx.go b/gfx/gfx.go index 9f2e713..cb2a1e7 100644 --- a/gfx/gfx.go +++ b/gfx/gfx.go @@ -130,7 +130,10 @@ func renderRacers(ctx context, colors map[*game.Team]pixel.RGBA, pic pixel.Pictu X: oldPos.X + ctx.tween*(newPos.X-oldPos.X), Y: oldPos.Y + ctx.tween*(newPos.Y-oldPos.Y), } - renderBaton(pos, ctx.w) + + batch := pixel.NewBatch(new(pixel.TrianglesData), nil) + renderBaton(pos, batch) + batch.Draw(ctx.w) } } @@ -198,13 +201,13 @@ func renderRacer(ctx context, oldRacer, racer game.Racer, active bool, c pixel.R im2.Draw(ctx.w) } -func renderBaton(pos pixel.Vec, w *pixelgl.Window) { +func renderBaton(pos pixel.Vec, b *pixel.Batch) { im := imdraw.New(nil) im.Color = colornames.Bisque im.Push(pos) im.Clear() im.Circle(batonWidth, 3) - im.Draw(w) + im.Draw(b) } func lanePos(pos, lane int, width float64, bounds pixel.Rect) pixel.Vec {