aboutsummaryrefslogtreecommitdiff
path: root/core/screen_shaker.lua
blob: 031655991fdbff1e00a082727564af0b19710c53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Class = require("libs.hump.class")
Shack = require("libs.shack")
local Timer = require("libs.hump.timer")

ScreenShaker = Class {
    init = function(self)
        monsterGrowl = love.audio.newSource("assets/sfx/monster_growl.wav", "static")
        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)
    monsterGrowl:play()
end

return ScreenShaker