From 77f087952dda8cd3608f578877dab3c667fedabc Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Mon, 28 Feb 2022 03:52:24 +0530 Subject: Adds Screen Shake on every 10 seconds --- utils/screen_shaker.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 utils/screen_shaker.lua (limited to 'utils') 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 -- cgit v1.2.3