From 9ac7a16333881ff2c3cfa3830e30c6474514e29f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 21 Sep 2020 01:13:00 +0900 Subject: [PATCH] examples/camera: Add limitations to the zoom factor --- examples/camera/main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/camera/main.go b/examples/camera/main.go index 4dde8802c..3542744e8 100644 --- a/examples/camera/main.go +++ b/examples/camera/main.go @@ -148,10 +148,14 @@ func (g *Game) Update(screen *ebiten.Image) error { } if ebiten.IsKeyPressed(ebiten.KeyQ) { - g.camera.ZoomFactor -= 1 + if g.camera.ZoomFactor > -240 { + g.camera.ZoomFactor -= 1 + } } if ebiten.IsKeyPressed(ebiten.KeyE) { - g.camera.ZoomFactor += 1 + if g.camera.ZoomFactor < 240 { + g.camera.ZoomFactor += 1 + } } if ebiten.IsKeyPressed(ebiten.KeyR) {