gameplay prototype
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
Timer :: struct {
|
||||
lifetime: f32,
|
||||
callback: proc(),
|
||||
}
|
||||
|
||||
timers: [dynamic]Timer
|
||||
|
||||
start_timer :: proc(time: f32, callback: proc()) {
|
||||
new_timer := Timer {
|
||||
lifetime = time,
|
||||
callback = callback,
|
||||
}
|
||||
append(&timers, new_timer)
|
||||
}
|
||||
|
||||
run_timers :: proc() {
|
||||
for &t, i in timers {
|
||||
t.lifetime -= rl.GetFrameTime()
|
||||
if t.lifetime <= 0 {
|
||||
unordered_remove(&timers, i)
|
||||
t.callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user