diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-11 02:39:28 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-11 02:39:28 +0200 |
commit | 9e2ec1aa5abb84d3e46c34ed407934ac54fce331 (patch) | |
tree | 723abf526f301d5e66659e1ae931c46e303f8a2f /not | |
parent | 6ed92013f8096057e4aad3f5a730e3586d9eb0e6 (diff) | |
download | roflnauts-9e2ec1aa5abb84d3e46c34ed407934ac54fce331.zip roflnauts-9e2ec1aa5abb84d3e46c34ed407934ac54fce331.tar.gz roflnauts-9e2ec1aa5abb84d3e46c34ed407934ac54fce331.tar.bz2 |
Some shake tweaking
Diffstat (limited to 'not')
-rw-r--r-- | not/Camera.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/not/Camera.lua b/not/Camera.lua index 8008a0d..8e74a76 100644 --- a/not/Camera.lua +++ b/not/Camera.lua @@ -1,8 +1,8 @@ --- Used in drawing other stuff in places. Camera = require "not.Object":extends() -Camera.SHAKE_LENGTH = 0.8 -Camera.SHAKE_INTERVAL = 0.04 +Camera.SHAKE_LENGTH = 0.6 +Camera.SHAKE_INTERVAL = 0.03 -- TODO: Camera would really make use of vec2s (other classes would use them too). function Camera:new (world) @@ -28,7 +28,7 @@ end function Camera:translate () local x, y = self:getPositionScaled() - local dx, dy = self:getShakeShift() + local dx, dy = self:getShakeScaled() love.graphics.push() love.graphics.translate(-x - dx, -y - dy) end @@ -103,7 +103,7 @@ function Camera:shake (dt) self.shakeTime = self.shakeTime - dt if self.shakeInterval < 0 then self.shakeShift.theta = self.shakeShift.theta - 1.3 + love.math.random() * 0.6 - self.shakeShift.radius = 80 * self.shakeTime + self.shakeShift.radius = 70 * self.shakeTime self.shakeInterval = Camera.SHAKE_INTERVAL else self.shakeShift.radius = self.shakeShift.radius * 0.66 @@ -115,12 +115,18 @@ function Camera:shake (dt) end end -function Camera:getShakeShift () +function Camera:getShake () local radius = self.shakeShift.radius local theta = self.shakeShift.theta * math.pi return radius * math.cos(theta), radius * math.sin(theta) end +function Camera:getShakeScaled () + local x, y = self:getShake() + local scale = getScale() + return x * scale, y * scale +end + function Camera:follow () local map = self.world.map local sum_x,sum_y,i = map.center.x, map.center.y, 1 |