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'
|
GameObject = require 'obj/GameObject'
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
|
-- slow_amntmo var
|
||||||
|
slow_amnt = 1
|
||||||
-- table of color palette
|
-- table of color palette
|
||||||
COLORS = {
|
COLORS = {
|
||||||
default = {1,1,1,1},
|
default = {1,1,1,1},
|
||||||
|
|
@ -87,7 +89,7 @@ function love.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
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)
|
input:update(dt)
|
||||||
if input:pressed('f1') then gotoRoom('CircleRoom') end
|
if input:pressed('f1') then gotoRoom('CircleRoom') end
|
||||||
if input:pressed('f2') and DEBUG then
|
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
|
for k, v in pairs(counts) do print(k, v) end
|
||||||
print("-------------------------------------")
|
print("-------------------------------------")
|
||||||
end
|
end
|
||||||
camera:update(dt)
|
camera:update(dt*slow_amnt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
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)
|
return (min > max and (love.math.random()*(min - max) + max)) or (love.math.random()*(max - min) + min)
|
||||||
end
|
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 --
|
-- garbage collection --
|
||||||
------------------------
|
------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue