batch bg
This commit is contained in:
parent
ea71f7ace9
commit
8b2890cd4f
11
gfx/gfx.go
11
gfx/gfx.go
|
@ -65,7 +65,8 @@ func loadPicture(path string) (pixel.Picture, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Render(rs RenderState, sOld, sNew game.State, w *pixelgl.Window, sb spriteBank) RenderState {
|
func Render(rs RenderState, sOld, sNew game.State, w *pixelgl.Window, sb spriteBank) RenderState {
|
||||||
renderBackground(w)
|
batch := pixel.NewBatch(new(pixel.TrianglesData), nil)
|
||||||
|
renderBackground(w, batch)
|
||||||
|
|
||||||
colors := teamColors(sNew.Teams)
|
colors := teamColors(sNew.Teams)
|
||||||
ctx := context{
|
ctx := context{
|
||||||
|
@ -86,9 +87,11 @@ func Render(rs RenderState, sOld, sNew game.State, w *pixelgl.Window, sb spriteB
|
||||||
|
|
||||||
var stars []pixel.Vec
|
var stars []pixel.Vec
|
||||||
|
|
||||||
func renderBackground(w *pixelgl.Window) {
|
func renderBackground(w *pixelgl.Window, batch *pixel.Batch) {
|
||||||
w.Clear(colornames.Black)
|
w.Clear(colornames.Black)
|
||||||
|
|
||||||
|
batch.Clear()
|
||||||
|
|
||||||
if len(stars) == 0 {
|
if len(stars) == 0 {
|
||||||
const numStars = 100
|
const numStars = 100
|
||||||
for i := 0; i < numStars; i++ {
|
for i := 0; i < numStars; i++ {
|
||||||
|
@ -106,7 +109,9 @@ func renderBackground(w *pixelgl.Window) {
|
||||||
im.Clear()
|
im.Clear()
|
||||||
}
|
}
|
||||||
im.Circle(2, 0)
|
im.Circle(2, 0)
|
||||||
im.Draw(w)
|
im.Draw(batch)
|
||||||
|
|
||||||
|
batch.Draw(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderRacers(ctx context, colors map[*game.Team]pixel.RGBA, pic pixel.Picture) {
|
func renderRacers(ctx context, colors map[*game.Team]pixel.RGBA, pic pixel.Picture) {
|
||||||
|
|
Loading…
Reference in New Issue