This commit is contained in:
Josh Deprez 2021-07-23 17:27:10 +10:00 committed by Josh Deprez
parent a2fb805f41
commit 680b2d5269

View file

@ -54,7 +54,7 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (w, h int) {
// Sort sorts the components by Z position. // Sort sorts the components by Z position.
// Non-Drawers are sorted before all Drawers. // Non-Drawers are sorted before all Drawers.
func (g *Game) Sort() { func (g *Game) Sort() {
// SliceStable to avoid z-fighting (among Non-Drawers and equal Drawers) // Stable sort to avoid z-fighting (among Non-Drawers and equal Drawers)
sort.SliceStable(g.Components, func(i, j int) bool { sort.SliceStable(g.Components, func(i, j int) bool {
a, aok := g.Components[i].(Drawer) a, aok := g.Components[i].(Drawer)
b, bok := g.Components[j].(Drawer) b, bok := g.Components[j].(Drawer)