From 44bc9aa6fa62c1b23d1e98de8729c72132a88abc Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 12 Sep 2017 01:45:36 +0200 Subject: Proper Camera scaling introduction --- not/Camera.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'not/Camera.lua') diff --git a/not/Camera.lua b/not/Camera.lua index 1fa01d3..c3aaae6 100644 --- a/not/Camera.lua +++ b/not/Camera.lua @@ -21,18 +21,26 @@ function Camera:initShake () } end +function Camera:push () + love.graphics.push() +end + +function Camera:scale (scale) + scale = scale or getScale() + love.graphics.scale(scale, scale) +end + -- TODO: Even more magic numbers present in Camera. Translate method. function Camera:translate (ratio) - local x, y = self:getPositionScaled() - local dx, dy = self:getShakeScaled() + local px, py = self:getPosition() + local dx, dy = self:getShake() if ratio then dx = dx * ratio dy = dy * ratio - x = x * ratio - y = y * ratio + px = px * ratio + py = py * ratio end - love.graphics.push() - love.graphics.translate(160*getScale() - x - dx, 90*getScale() - y - dy) + love.graphics.translate(160 - px - dx, 90 - py - dy) end function Camera:pop () -- cgit v1.1