call it pf

This commit is contained in:
Josh Deprez 2021-08-18 17:44:03 +10:00
parent 88482c390d
commit f01b667a0d

View file

@ -74,7 +74,7 @@ func (c *Camera) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) {
// Apply other options // Apply other options
opts.Filter = c.Filter opts.Filter = c.Filter
// Compute common matrix (parts independent of CoordScale). // Compute common matrix (parts independent of parallax).
// Moving centre to the origin happens per component. // Moving centre to the origin happens per component.
var comm ebiten.GeoM var comm ebiten.GeoM
// 2. Zoom (this is also where rotation would be) // 2. Zoom (this is also where rotation would be)
@ -87,13 +87,13 @@ func (c *Camera) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) {
// Draw everything. // Draw everything.
for _, i := range c.Scene.Components { for _, i := range c.Scene.Components {
if d, ok := i.(Drawer); ok { if d, ok := i.(Drawer); ok {
cs := 1.0 pf := 1.0
if s, ok := i.(ParallaxScaler); ok { if s, ok := i.(ParallaxScaler); ok {
cs = s.ParallaxFactor() pf = s.ParallaxFactor()
} }
var geom ebiten.GeoM var geom ebiten.GeoM
// 1. Move centre to the origin, subject to CoordScale // 1. Move centre to the origin, subject to parallax factor
geom.Translate(-float64(centre.X)*cs, -float64(centre.Y)*cs) geom.Translate(-float64(centre.X)*pf, -float64(centre.Y)*pf)
geom.Concat(comm) geom.Concat(comm)
opts.GeoM = geom opts.GeoM = geom
d.Draw(screen, opts) d.Draw(screen, opts)