call it pf
This commit is contained in:
parent
88482c390d
commit
f01b667a0d
1 changed files with 5 additions and 5 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue