From 3c399d6ea4ad3528f1845944bb6d5b00697d2c0b Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Sun, 15 Jun 2025 20:27:31 +1200 Subject: Add punch feature + knockback etc, lots of cool shit --- assets/scripts/mainMenu.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'assets/scripts/mainMenu.lua') 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 -- cgit v1.2.3