Skip to content

Instantly share code, notes, and snippets.

@aib
Created July 8, 2012 11:56
Show Gist options
  • Save aib/3070645 to your computer and use it in GitHub Desktop.
Save aib/3070645 to your computer and use it in GitHub Desktop.
while (runMainLoop) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
runMainLoop = false;
}
}
keystate = SDL_GetKeyState(NULL);
buttonstate = SDL_GetMouseState(&mousex, &mousey);
cont->mouseMove(mousex, mousey);
cont->updateFromSDLKeyState(keystate, buttonstate);
//Draw the scene
Uint32 curTime = SDL_GetTicks();
if ((curTime-lastThinkTime) >= (1000 / THINKS_PER_SEC)) {
// p->Think();
lastThinkTime = curTime;
}
double framesElapsed = ((double)(curTime-lastFrameTime) / (double)(1000 / THINKS_PER_SEC));
glClear(GL_COLOR_BUFFER_BIT);
cont->Update(framesElapsed);
p->Update(framesElapsed);
updateEntities(framesElapsed);
m->Draw(framesElapsed);
p->Draw();
lastFrameTime = curTime;
SDL_GL_SwapBuffers();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment