Ejemplo n.º 1
0
void CIwGameAudio::Init()
{
	// initialise IwSound
	IwSoundInit();

	// Turn music and sound on
	SoundOn = true;
	MusicOn = true;
	SoundVolume = 1.0f;
	MusicVolume = 1.0f;

	// Used to convert our WAV's located in the resource group files
#ifdef IW_BUILD_RESOURCES
	IwGetResManager()->AddHandler(new CIwResHandlerWAV);
#endif

	// Mark audio as available
	Available = true;
//	Available = false;

	// Set default music codec to MP3
	MusicCodec = S3E_AUDIO_CODEC_MP3;

	// Create a sound collection
	SoundCollection = new CIwGameSoundCollection();
}
Ejemplo n.º 2
0
void ResourceManager::init() {
	IwSoundInit();
	IwResManagerInit();
#ifdef IW_BUILD_RESOURCES
	IwGetResManager()->AddHandler(new CIwResHandlerWAV);
#endif
	IwGetResManager()->LoadGroup("sounds.group");
	imgs = new map<string, SImg>();
	sounds = new map<int, Sound>();
}
Ejemplo n.º 3
0
//
// Audio class
//
Audio::Audio()
{
    // Initialise IwSound
    IwSoundInit();
}
Ejemplo n.º 4
0
void Game::mainLoop()
{
    // initialize
    deltaTime = 0;

    // TODO: create a config file and move these there
    const uint64 TARGET_FRAME_MS = 16;
    const uint64 MAX_FRAME_MS = 100;

    // init assets
    AssetFactory::getInstance().init();

		//init resource manager
#ifdef IW_BUILD_RESOURCES
	IwGetResManager()->AddHandler(new CIwResHandlerWAV);
#endif

#ifdef _DEBUG
	IwGetResManager()->LoadGroup("TestLevel.group");
#endif

    // create level
    //LevelManager::getInstance().pushLevel(new MainMenu(this));
    LevelManager::getInstance().pushLevel(new TestLevel());
    LevelManager::getInstance().getActiveLevel()->initialize();

    // init input
    Input::getInstance();
	
	//Init sound and resmanager
	//IwGxInit();
	//Iw2DInit();
	//Iw2DSetAlphaMode(IW_2D_ALPHA_HALF);
	IwSoundInit();
	IwResManagerInit();


	IwGetResManager()->LoadGroup("TestLevel.group");

    // loop
    while( !quit )
    {
        //s3eDeviceYield(0); // S3E applications should yield frequently
        uint64 time = s3eTimerGetMs();

		if ( s3eDeviceCheckQuitRequest() ) {
			quit = true;
		}

		IwGetSoundManager()->Update();
		update();
		render();

        deltaTime = s3eTimerGetMs() - time;
        int yield = 0;

        if (deltaTime < TARGET_FRAME_MS) {
            yield = TARGET_FRAME_MS - deltaTime;
            deltaTime = TARGET_FRAME_MS;
        } else if (deltaTime > MAX_FRAME_MS) {
            deltaTime = MAX_FRAME_MS;
        }

        s3eDeviceYield(yield);
    }

    // clean up
    Input::getInstance().unregister();

	IwSoundTerminate();
	IwResManagerTerminate();
	Iw2DTerminate();
}