From ed61e27440e44ba92fee7a1071e472a8d7aa841b Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Mon, 9 Aug 2021 15:00:25 +1000 Subject: [PATCH] camera tweaks --- engine/camera.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/camera.go b/engine/camera.go index 26908c3..ca88a54 100644 --- a/engine/camera.go +++ b/engine/camera.go @@ -12,6 +12,7 @@ type Camera struct { Transform GeoMDef game *Game + // TODO: camera constraints } func (c *Camera) Draw(screen *ebiten.Image, geom ebiten.GeoM) { @@ -25,6 +26,7 @@ func (c *Camera) Scan() []interface{} { return []interface{}{c.Scene} } func (c *Camera) Prepare(game *Game) { c.game = game } +// Centre centres the camera on a world coordinate. func (c *Camera) Centre(p image.Point) { // Currently the centre of the screen c is A^-1.c in world coordinates // So it is off by (p - A^-1.c) @@ -35,7 +37,5 @@ func (c *Camera) Centre(p image.Point) { t.Invert() } -func (c *Camera) Zoom(f float64) { - t := c.Transform.GeoM() - t.Scale(f, f) -} +// Zoom scales the existing camera transform by f along both X and Y. +func (c *Camera) Zoom(f float64) { c.Transform.GeoM().Scale(f, f) }