Skip to content

Instantly share code, notes, and snippets.

@H2CO3
Created April 30, 2015 12:02
Show Gist options
  • Save H2CO3/897c646dd8128539d6d6 to your computer and use it in GitHub Desktop.
Save H2CO3/897c646dd8128539d6d6 to your computer and use it in GitHub Desktop.
let SDL = dynld("sdl2");
var timers = {};
let timerWithEvent = fn (dt, callback) {
let tmr = SDL::StartTimer(dt);
timers[tmr] = callback;
};
timerWithEvent(0.5, fn {
print("Timer fired!");
});
var run = true;
while run {
var e;
while (e = SDL::PollEvent()) != nil {
if e.type == "timer" {
timers[e.ID]();
}
if e.type == "quit" {
run = false;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment