void playSoundtrack(const char *filename) { #ifdef USE_SOUND if(music == NULL) { music = Mix_LoadMUS(filename); // Load the music Mix_PlayMusic(music, -1); // Loop infinitely Mix_VolumeMusic(10); // Set volume } else { //TODO: add a transition between soundtracks stopSoundtrack(); playSoundtrack(filename); } #endif }
void Gameplay::entityInit(Object * p) { // load config _config = new TiXmlDocument( "./cfg/config.xml" ); _config->LoadFile(); // read pitch shift option TiXmlElement* xmlSound = Gameplay::iGameplay->getConfigElement( "sound" ); assert( xmlSound ); int pitchShift; xmlSound->Attribute( "pitchShift", &pitchShift ); _pitchShiftIsEnabled = ( pitchShift != 0 ); // read cheats option TiXmlElement* details = Gameplay::iGameplay->getConfigElement( "details" ); assert( details ); int cheats; details->Attribute( "cheats", &cheats ); _cheatsEnabled = ( cheats != 0 ); // read free jumping mode int freemode; details->Attribute( "freemode", &freemode ); _freeModeIsEnabled = ( freemode != 0 ); // read meters / feet mode int units; details->Attribute( "units", &units ); _feetModeIsEnabled = ( units != 0 ); // setup random number generation getCore()->getRandToolkit()->setSeed( GetTickCount() ); // retrieve interfaces queryInterface( "Engine", &iEngine ); assert( iEngine ); queryInterface( "Gui", &iGui ); assert( iGui ); queryInterface( "Language", &iLanguage ); assert( iLanguage ); queryInterface( "Input", &iInput ); assert( iInput ); queryInterface( "Audio", &iAudio ); assert( iAudio ); if( !iAudio || !iInput || !iLanguage || !iGui || !iEngine ) { throw Exception( "One or more core modules are not found, so gameplay will Crash Right Now!" ); } // check language module if( wcscmp( iLanguage->getVersionString(), ::version.getVersionString() ) != 0 ) { // incompatible module? - show no localization data iLanguage->reset(); } getCore()->logMessage("Version: %ls (Clean)", ::version.getVersionString()); // create input device _inputDevice = iInput->createInputDevice(); createActionMap(); // create physics resources foundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback); gPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, PxTolerancesScale() ); pxCooking = PxCreateCooking(PX_PHYSICS_VERSION, *foundation, PxCookingParams(PxTolerancesScale())); PxInitExtensions(*gPhysicsSDK); //PHYSX3 //NxGetPhysicsSDK()->setParameter( NX_VISUALIZATION_SCALE, 100.0f ); //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_ACTOR_AXES, 1 ); //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_COLLISION_SHAPES, 1 ); //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_COLLISION_STATIC, 1 ); //NxGetPhysicsSDK()->setParameter( NX_VISUALIZE_COLLISION_DYNAMIC,1 ); // generate user community events from XML documents generateUserCommunityEvents(); // open index TiXmlDocument* index = new TiXmlDocument( "./usr/index.xml" ); index->LoadFile(); // enumerate career nodes TiXmlNode* child = index->FirstChild(); if( child ) do { if( child->Type() == TiXmlNode::ELEMENT && strcmp( child->Value(), "career" ) == 0 ) { _careers.push_back( new Career( static_cast<TiXmlElement*>( child ) ) ); } child = child->NextSibling(); } while( child != NULL ); // close index document delete index; // create career for LICENSED_CHAR #ifdef GAMEPLAY_EDITION_ATARI createLicensedCareer(); #endif // determine afterfx configuration TiXmlElement* video = getConfigElement( "video" ); assert( video ); int afterfx = 0; video->Attribute( "afterfx", &afterfx ); // create render target if( afterfx && iEngine->isPfxSupported( engine::pfxBloom ) && iEngine->isPfxSupported( engine::pfxMotionBlur ) ) { _renderTarget = new AfterFxRT(); } else { _renderTarget = new SimpleRT(); } // play menu music playSoundtrack( "./res/sounds/music/dirty_moleculas_execution.ogg" ); // evaluation protection #ifdef GAMEPLAY_EVALUATION_TIME SYSTEMTIME evaluationTime = GAMEPLAY_EVALUATION_TIME; SYSTEMTIME latestFileTime; if( getLatestFileTimeB( &latestFileTime ) ) { if( isGreaterTime( &latestFileTime, &evaluationTime ) ) { pushActivity( new Messagebox( Gameplay::iLanguage->getUnicodeString( 765 ) ) ); } else { // startup _preloaded = new Preloaded(); pushActivity( _preloaded ); } } #else // determine if licence is required to play game bool licenceIsRequired = false; #ifndef GAMEPLAY_EDITION_ND #ifndef GAMEPLAY_EDITION_ATARI #ifndef GAMEPLAY_EDITION_POLISH licenceIsRequired = false; #endif #endif #endif // startup _preloaded = new Preloaded(); pushActivity( _preloaded ); #endif }