diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-12 01:45:36 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-12 01:45:36 +0200 |
commit | 44bc9aa6fa62c1b23d1e98de8729c72132a88abc (patch) | |
tree | b1505717b590f7e8ba3c93c2899da1b739a49c4b /not/Camera.lua | |
parent | 9b047199eb4b90c16101b70dcd2405e0d37f7283 (diff) | |
download | roflnauts-44bc9aa6fa62c1b23d1e98de8729c72132a88abc.zip roflnauts-44bc9aa6fa62c1b23d1e98de8729c72132a88abc.tar.gz roflnauts-44bc9aa6fa62c1b23d1e98de8729c72132a88abc.tar.bz2 |
Proper Camera scaling introduction
Diffstat (limited to 'not/Camera.lua')
-rw-r--r-- | not/Camera.lua | 20 |
1 files changed, 14 insertions, 6 deletions
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 () |