From 056f0cf5d57842b11cc44e6976aeae25e3649c15 Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Thu, 26 Aug 2021 09:55:55 +1000 Subject: [PATCH] logic flip --- engine/camera.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/engine/camera.go b/engine/camera.go index be4b2f8..097ab50 100644 --- a/engine/camera.go +++ b/engine/camera.go @@ -87,18 +87,20 @@ func (c *Camera) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) { // Draw everything. for _, i := range c.Scene.Scan() { - if d, ok := i.(Drawer); ok { - pf := 1.0 - if s, ok := i.(ParallaxScaler); ok { - pf = s.ParallaxFactor() - } - var geom ebiten.GeoM - // 1. Move centre to the origin, subject to parallax factor - geom.Translate(-float64(centre.X)*pf, -float64(centre.Y)*pf) - geom.Concat(comm) - opts.GeoM = geom - d.Draw(screen, opts) + d, ok := i.(Drawer) + if !ok { + continue } + pf := 1.0 + if s, ok := i.(ParallaxScaler); ok { + pf = s.ParallaxFactor() + } + var geom ebiten.GeoM + // 1. Move centre to the origin, subject to parallax factor + geom.Translate(-float64(centre.X)*pf, -float64(centre.Y)*pf) + geom.Concat(comm) + opts.GeoM = geom + d.Draw(screen, opts) } }