All pastes #510970 Raw Edit

Test SDL Engine

public cpp v1 · immutable
#510970 ·published 2007-05-26 05:11 UTC
rendered paste body
void GameEngine::HandleEvent( SDL_Event event ){     switch (event.type)     {       //If the window focus changed       case SDL_ACTIVEEVENT:         //If the window lost or gained keyboard focus         if ( event.active.state & SDL_APPINPUTFOCUS )         {              //If the application has gained focus              if ( event.active.gain == 1 )              {                   GameActivate();//                   SetSleep(false);              }              else // If the application no longer has focus              {                   GameDeactivate();//                   SetSleep(true);              }         }         break;       //If a key was pressed       case SDL_KEYDOWN:         HandleKeyDown(event.key.keysym.sym);         break;       case SDL_KEYUP:         HandleKeyUp(event.key.keysym.sym);         break;       case SDL_MOUSEBUTTONDOWN:         MouseButtonDown(event.button.x, event.button.y, event.button.button);         break;       case SDL_MOUSEBUTTONUP:         MouseButtonUp(event.button.x, event.button.y,event.button.button);         break;       case SDL_MOUSEMOTION:         MouseMove(event.button.x, event.button.y);       case SDL_VIDEOEXPOSE:         GamePaint();         break;       case SDL_QUIT:         // End the game and exit the application         GameEnd();         break;     }}//Enter the main message loop      while(true)      {        if( SDL_PollEvent(&event) )        {            // Process the message            GameEngine::GetEngine()->HandleEvent( event );        }        else        {            if (!GameEngine::GetEngine()->GetSleep())            {               // Check thetick count to see if a game cycle has elapsed               iTickCount = SDL_GetTicks();               if (iTickCount > iTickTrigger)               {                  iTickTrigger = iTickCount +                               GameEngine::GetEngine()->GetFrameDelay();                  GameCycle();               }            }        }      }