Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7283 in orxonox.OLD for trunk/src/story_entities/game_world.cc


Ignore:
Timestamp:
Apr 13, 2006, 7:15:37 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: thread for audio, and 'is' to 'b'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/game_world.cc

    r7221 r7283  
    8989
    9090  this->dataXML = NULL;
     91
     92  this->audioThread = NULL;
    9193}
    9294
     
    100102{
    101103  PRINTF(4)("Deleted GameWorld\n");
     104
     105  if (this->audioThread != NULL)
     106    SDL_KillThread(this->audioThread);
    102107}
    103108
     
    131136}
    132137
     138int GameWorld::createAudioThread(void* gameWorld)
     139{
     140  GameWorld* gw = (GameWorld*)gameWorld;
     141  printf("STARTIG AUDIO THREAD\n");
     142  while (gw->bRunning)
     143  {
     144    if(gw->dataTank->music != NULL)
     145      gw->dataTank->music->playback();
     146    SDL_Delay(5);
     147  }
     148  printf("End the AudioThread\n");
     149}
    133150
    134151/**
     
    199216bool GameWorld::start()
    200217{
    201   this->isPaused = false;
    202   this->isRunning = true;
     218  this->bPaused = false;
     219  this->bRunning = true;
     220
     221  if (this->audioThread == NULL)
     222    this->audioThread = SDL_CreateThread(GameWorld::createAudioThread, (void*)this);
    203223
    204224  this->run();
     
    212232{
    213233  PRINTF(3)("GameWorld::stop() - got stop signal\n");
    214   this->isRunning = false;
     234  this->bRunning = false;
     235
     236//  SDL_KillThread(this->audioThread);
     237  this->audioThread = NULL;
    215238}
    216239
     
    221244bool GameWorld::pause()
    222245{
    223   this->isPaused = true;
     246  this->bPaused = true;
    224247}
    225248
     
    230253bool GameWorld::resume()
    231254{
    232   this->isPaused = false;
     255  this->bPaused = false;
    233256}
    234257
     
    243266void GameWorld::run()
    244267{
    245   /* start the music */
    246   if(this->dataTank->music != NULL)
    247     this->dataTank->music->playback();
    248 
    249268  PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n");
    250269
     
    256275  this->lastFrame = SDL_GetTicks ();
    257276
    258   while( this->isRunning) /* @todo implement pause */
     277  while( this->bRunning) /* @todo implement pause */
    259278  {
    260279    /* process intput */
    261280    this->handleInput ();
    262     if( !this->isRunning)
     281    if( !this->bRunning)
    263282      break;
    264283
     
    326345  Uint32 currentFrame = SDL_GetTicks();
    327346
    328   if( !this->isPaused)
     347  if( !this->bPaused)
    329348  {
    330349    // CALCULATE FRAMERATE
Note: See TracChangeset for help on using the changeset viewer.