From 6d75313ee4b642e9ff7f73016a0d723b5c642180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ritzl?= Date: Sat, 8 Dec 2018 23:10:15 +0100 Subject: [PATCH] Fixed bounds calculation --- orthographic/camera.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/orthographic/camera.lua b/orthographic/camera.lua index a0b5d58..b71ef42 100644 --- a/orthographic/camera.lua +++ b/orthographic/camera.lua @@ -258,15 +258,16 @@ function M.update(camera_id, dt) local bl_offset = bl + OFFSET local bounds_width = tr.x - bl.x - if bounds_width < WINDOW_WIDTH then - cp.x = bl.x + (tr.x - bl.x) / 2 + if bounds_width < DISPLAY_WIDTH then + cp.x = bl.x + bounds_width / 2 else cp.x = math.max(cp.x, bl_offset.x) cp.x = math.min(cp.x, tr_offset.x) end + local bounds_height = tr.y - bl.y - if bounds_height < WINDOW_HEIGHT then - cp.y = bl.y + (tr.y - bl.y) / 2 + if bounds_height < DISPLAY_HEIGHT then + cp.y = bl.y + bounds_height / 2 else cp.y = math.max(cp.y, bl_offset.y) cp.y = math.min(cp.y, tr_offset.y)