move SDL event handling to a function, to make the main

loop simpler
This commit is contained in:
Glenn Maynard
2003-03-17 06:20:57 +00:00
parent bbb416d615
commit be78746167
+15 -12
View File
@@ -500,13 +500,7 @@ static void HandleInputEvents(float fDeltaTime)
}
}
static void GameLoop()
{
for(int hack = 0; hack < 1024; ++hack)
SDL_PumpEvents();
RageTimer timer;
while(1)
static bool HandleSDLEvents()
{
// process all queued events
SDL_Event event;
@@ -519,7 +513,7 @@ static void GameLoop()
{
case SDL_QUIT:
LOG->Trace("SDL_QUIT: shutting down");
return; /* exit the main loop */
return false; /* exit the main loop */
case SDL_VIDEORESIZE:
DISPLAY->ResolutionChanged(event.resize.w, event.resize.h);
break;
@@ -543,6 +537,17 @@ static void GameLoop()
}
}
return true;
}
static void GameLoop()
{
RageTimer timer;
while(1)
{
if(!HandleSDLEvents())
return; /* exit the main loop (quit) */
/*
* Update
*/
@@ -562,16 +567,14 @@ static void GameLoop()
SCREENMAN->Update( fDeltaTime );
SOUNDMAN->Update( fDeltaTime );
/* Important: Process input AFTER updaing game logic, or input will be acting on song beat from last frame */
/* Important: Process input AFTER updating game logic, or input will be acting on song beat from last frame */
HandleInputEvents( fDeltaTime );
/*
* Render
*/
DISPLAY->Clear();
SCREENMAN->Draw(); // draw the game
SCREENMAN->Draw();
DISPLAY->Flip();
if(g_bHasFocus)