pico-sdl
Loading...
Searching...
No Matches
event_loop.c
// file: event_loop.c
#include <pico.h>
int main() {
while (1) {
int timeout = 16, accum = 0; // timeout is 1000 / FRAMERATE
while (timeout > 0) {
int before = pico_get_ticks();
SDL_Event event;
pico_input_event_timeout(&event, 0, timeout);
if (event.type == SDL_QUIT) {
break;
}
// process events ...
int delta = pico_get_ticks() - before;
timeout -= delta;
accum += delta;
}
float delta = 0.001f * accum;
// update ...
// draw ...
}
return 0;
}
void pico_init(int on)
Initializes and terminates pico.
int pico_input_event_timeout(Pico_Event *evt, int type, int timeout)
Stops the program until an event occurs or a timeout is reached.
void pico_output_clear(void)
Clears screen with color set by pico_set_color_clear.
void pico_output_present(void)
Shows what has been drawn onto the screen. Only does anything on expert mode.
Uint32 pico_get_ticks(void)
Gets the amount of ticks that passed since pico was initialized.