diff options
Diffstat (limited to 'assets/scripts/mainMenu.lua')
| -rw-r--r-- | assets/scripts/mainMenu.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/assets/scripts/mainMenu.lua b/assets/scripts/mainMenu.lua index 05272af..4854775 100644 --- a/assets/scripts/mainMenu.lua +++ b/assets/scripts/mainMenu.lua @@ -22,6 +22,32 @@ Input = { end } +Timer = { + timers = {} +} + +function Timer.after(delay, callback) + table.insert(Timer.timers, { + time = delay, + action = callback + }) +end + +function Timer.clearAllTimers() + Timer.timers = {} +end + +function Timer.update(dt) + for i = #Timer.timers, 1, -1 do + local t = Timer.timers[i] + t.time = t.time - dt + if t.time <= 0 then + t.action() + table.remove(Timer.timers, i) + end + end +end + function Setup() setBgImage("assets/backgrounds/city-background-1.png") end |
