Ejemplo n.º 1
0
/**
 * Show the game introduction
 */
void MortevielleEngine::showIntroduction() {
	_dialogManager->displayIntroScreen(false);
	_dialogManager->checkForF8(142, false);
	if (shouldQuit())
		return;

	_dialogManager->displayIntroFrame2();
	_dialogManager->checkForF8(143, true);
	if (shouldQuit())
		return;

	showTitleScreen();
	music();
	_mixer->stopAll();
}
int main ( int argc, char **argv ) {
  
  SDL_Surface *video;
  SDL_Event event;
  
  Level level;
  level.camera.set( 0, 200, 0 );
  level.cameraSpeed.set( 0, 0, 0 );
  level.player.bodyRep.position.set( 6, 2, 1 );
  level.player.bodyRep.speed.set( 0, 0, 0 );

  initLevel( level );

  SDL_Init( SDL_INIT_EVERYTHING );

  if ( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 ) {
      std::cout << "Could not start sound system..." << std::endl;
      playSounds = false;
    } else {
      jetSound = Mix_LoadWAV( "res/jet.wav" );
      gotIt = Mix_LoadWAV( "res/gotIt.wav" );
      //      step = Mix_LoadWAV( "res/step.wav" );
      std::cout << "Sound ready!" << std::endl;
      playSounds = true;
  }
  
  video = SDL_SetVideoMode( 640, 480, 0, 0 );
  
  showTitleScreen( video );
  
  clock_t t0;
  clock_t t1;
  float delta;

  while ( running ) {
    
    t0 = clock();

    level.updateGame( gotIt, step, video );
    refreshScreen( video, level );
    
    
    if ( SDL_PollEvent( &event ) ) {
      
      if( event.type == SDL_QUIT ) {
	running = false;
      }
      
      handleEvents( event, level );
    }

    t1 = clock();
 
    delta = ((((float) t1 ) - ((float)t0)) / CLOCKS_PER_SEC );
    
    SDL_Delay( 50 - ( 1000 * delta ) );
  }
  
  SDL_FreeSurface( video );
  Mix_FreeChunk( jetSound );
  
  SDL_Quit();
  
  return 0;
}