aboutsummaryrefslogtreecommitdiff
path: root/utils/screen_shaker.lua
diff options
context:
space:
mode:
Diffstat (limited to 'utils/screen_shaker.lua')
-rw-r--r--utils/screen_shaker.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/utils/screen_shaker.lua b/utils/screen_shaker.lua
new file mode 100644
index 0000000..ca996af
--- /dev/null
+++ b/utils/screen_shaker.lua
@@ -0,0 +1,26 @@
+Class = require("libs.hump.class")
+Shack = require("libs.shack")
+local Timer = require("libs.hump.Timer")
+
+ScreenShaker = Class {
+ init = function(self)
+ local width, height = love.graphics.getDimensions()
+ Shack:setDimensions(width, height)
+ Timer.every(10, shakeScreen)
+ end
+}
+
+function ScreenShaker:update(dt)
+ Timer.update(dt)
+ Shack:update(dt)
+end
+
+function ScreenShaker:draw()
+ Shack:apply()
+end
+
+function shakeScreen()
+ Shack:setShake(20)
+end
+
+return ScreenShaker \ No newline at end of file