int main(int argc, char** argv)
{
  SDL_Event event;

  int keypress = 0;
    
  // Init random number generator
  srand(clock());

  // Init everything
  sdl_init("OpenGL example");
  opengl_init();
  audioplayer_init();
  
  // Init internal data
  init_sin_table();
  init_textures();
  
  // Load audioplayer tune
  audioplayer_loadtune(&simpletune);
  audioplayer_play();
  
  // Loop until the end
  while(!keypress && audioplayer_isplaying()) 
  {
    // Lock SDL surface if needed
    if(SDL_MUSTLOCK(screen)) 
      if(SDL_LockSurface(screen) < 0)
	exit(EXIT_FAILURE);
  
    // Draw the plasma
    draw_cube(screen, audioplayer_getpos());

    // Unlock the SDL surface if needed
    if(SDL_MUSTLOCK(screen))
      SDL_UnlockSurface(screen);
  
    // Update screen
    SDL_GL_SwapBuffers();
      
    // Handle SDL events
    while(SDL_PollEvent(&event)) 
    {      
      switch (event.type) 
      {
	case SDL_QUIT:
	case SDL_KEYDOWN:
	  keypress = 1;
	  break;
      }
    }
  }
  
  // Exit gracefully
  SDL_Quit();
  return EXIT_SUCCESS;
}
Exemple #2
0
void game_pause(Game * game,int state){
	if(state){
		printf("PAUSE\n");
		audioplayer_pause(game->audio);
		//TODO PAUSE MUSIC
	}else{
		printf("PLAY\n");
		audioplayer_play(game->audio);
		//TODO UNPAUSE MUSIC
	}
}