void Engine::start( ) { if( engineState != initializing ) return; apply_surface( 0, 0, background, screen ); for( int i=0; i<4; i++ ) { for( int j=0; j<6; j++ ) { square[i][j].SetPosition( ( j*170 ) +28, ( i*170 )+150 ); } } square[3][0].Undead = true; square[0][5].Undead = true; square[3][0].Load( true ); square[0][5].Load( true ); square[3][0].setClip( 0 ); square[0][5].setClip( 0 ); engineState = Engine::showingSplash; while( !isExiting( ) ) { EngineLoop(); } SDL_Quit(); }
void Engine::Start(const char* title, int width, int height, bool fullscreen) { int flags = 0; SDL_Init(SDL_INIT_EVERYTHING); SDL_WM_SetCaption(title, title); // load support for the JPG and PNG image formats flags=IMG_INIT_JPG|IMG_INIT_PNG; int initted=IMG_Init(flags); if(initted&flags != flags) { std::cout << "IMG_Init: Failed to init required jpg and png support!\n"; std::cout << "IMG_Init:" << IMG_GetError(); // handle error } if( fullscreen ) { flags = SDL_FULLSCREEN; } m_pCanvas = SDL_SetVideoMode(width, height, 32, SDL_SWSURFACE); m_bFullscreen = fullscreen; m_bRunning = true; std::cout << "Engine Initialised" << std::endl; ChangeState(PlayingGame::Instance()); while(Running()) { EngineLoop(); } // cleanup the Engine CleanUp(); }