/* Initialise game-specific things. Base class just calls InitialiseObjects() to create the moving objects */ int BaseEngine::GameInit() { // Create the moving objects InitialiseObjects(); // Set up the initial background SetupBackgroundBuffer(); return 0; // success }
/* Handle any key presses here. Note that the objects themselves (e.g. player) may also check whether a key is pressed */ void Demo4Main::KeyDown(int iKeyCode) { // NEW SWITCH switch ( iKeyCode ) { case SDLK_ESCAPE: // End program when escape is pressed SetExitWithCode( 0 ); break; case SDLK_SPACE: // SPACE Pauses switch( m_state ) { case stateInit: // Go to state main m_state = stateMain; // Force redraw of background SetupBackgroundBuffer(); // Redraw the whole screen now Redraw(true); break; case stateMain: // Go to state paused m_state = statePaused; // Force redraw of background SetupBackgroundBuffer(); // Redraw the whole screen now Redraw(true); break; case statePaused: // Go to state main m_state = stateMain; // Force redraw of background SetupBackgroundBuffer(); // Redraw the whole screen now Redraw(true); break; } // End switch on current state break; // End of case SPACE } }
// Override to handle a mouse press void MyProjectMain::MouseDown( int iButton, int iX, int iY ) { // Redraw the background SetupBackgroundBuffer(); Redraw(true); // Force total redraw }
// Override to handle a mouse press void SimpleDemo::MouseDown( int iButton, int iX, int iY ) { // Redraw the background SetupBackgroundBuffer(); Redraw(true); // Force total redraw }