#include "jgame.h" #include "jdraw.h" #include "jinput.h" #include namespace game { static unsigned int ticks_per_frame = 1000/60; void setUpdateTicks(const int ticks) { ticks_per_frame = ticks; } } int main(int argc, char *argv[]) { game::init(); input::init(); static unsigned int current_ticks = SDL_GetTicks(); bool should_exit=false; SDL_Event e; while (!should_exit) { uint8_t keyp=SDL_SCANCODE_UNKNOWN, keydown=SDL_SCANCODE_UNKNOWN; while(SDL_PollEvent(&e)) { if (e.type==SDL_QUIT) { should_exit = true; break; } if (e.type==SDL_KEYDOWN) { keydown = e.key.keysym.scancode; } if (e.type==SDL_KEYUP) { keyp = e.key.keysym.scancode; } } input::update(keydown,keyp); if (SDL_GetTicks()-current_ticks >= game::ticks_per_frame) { if (!game::loop()) should_exit = true; current_ticks = SDL_GetTicks(); } } return 0; }