add slowmo function
This commit is contained in:
parent
74f515a385
commit
f86d0dabf0
1 changed files with 13 additions and 2 deletions
15
main.lua
15
main.lua
|
|
@ -31,6 +31,8 @@ Area = require 'obj/Area'
|
|||
GameObject = require 'obj/GameObject'
|
||||
|
||||
function love.load()
|
||||
-- slow_amntmo var
|
||||
slow_amnt = 1
|
||||
-- table of color palette
|
||||
COLORS = {
|
||||
default = {1,1,1,1},
|
||||
|
|
@ -87,7 +89,7 @@ function love.load()
|
|||
end
|
||||
|
||||
function love.update(dt)
|
||||
if current_room then current_room:update(dt) end
|
||||
if current_room then current_room:update(dt*slow_amnt) end
|
||||
input:update(dt)
|
||||
if input:pressed('f1') then gotoRoom('CircleRoom') end
|
||||
if input:pressed('f2') and DEBUG then
|
||||
|
|
@ -114,7 +116,7 @@ function love.update(dt)
|
|||
for k, v in pairs(counts) do print(k, v) end
|
||||
print("-------------------------------------")
|
||||
end
|
||||
camera:update(dt)
|
||||
camera:update(dt*slow_amnt)
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
|
|
@ -210,6 +212,15 @@ function random(min, max)
|
|||
return (min > max and (love.math.random()*(min - max) + max)) or (love.math.random()*(max - min) + min)
|
||||
end
|
||||
|
||||
---Slows down gameplay
|
||||
---@param amount number percentage to which game will slow down
|
||||
---@param duration number duration in seconds of slow down
|
||||
---@param t Timer|nil optional timer object for optimization
|
||||
function slow(amount, duration, t)
|
||||
local timer = t or Timer()
|
||||
timer:tween(duration, _G, {slow_amnt = amount}, 'im-out-quad')
|
||||
end
|
||||
|
||||
------------------------
|
||||
-- garbage collection --
|
||||
------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue