示例#1
0
Sound	* Sound::CreateMusic(const String & fileName, eType type, int32 priority /*= 0*/)
{
    if(TYPE_STATIC != type && TYPE_STREAMED != type && TYPE_MANAGED != type)
        return 0;
    
#if defined(__DAVAENGINE_IPHONE__)
    Sound * sound = new MusicIos(fileName);
    if(!sound->Init())
    {
        SafeRelease(sound);
    }
    else
    {
        SoundSystem::Instance()->GroupMusic()->AddSound(sound);
    }
    return sound;
#else
	Sound * sound = new Sound(fileName, type, priority);
    if(!sound->Init())
    {
        SafeRelease(sound);
    }
    else
    {
        SoundSystem::Instance()->GroupMusic()->AddSound(sound);
    }
	return sound;
#endif //#if defined(__DAVAENGINE_IPHONE__)
}
示例#2
0
Sound	* Sound::CreateFX(const String & fileName, eType type, int32 priority /*= 0*/)
{
	Sound * sound = new Sound(fileName, type, priority);
	SoundSystem::Instance()->GroupFX()->AddSound(sound);
	sound->Init();
	return sound;
}
Sound* SoundManager::Create(const String& pSoundFileName, Bool pIs3DSound)
{
    // Ask the sound subsystem to create a sound for us.
    Sound* sound = Cast<Sound>(SoundSubsystem::Instance()->Create(Sound::StaticClass()));

    std::map<String, SoundData*>::iterator itFind = mLoadedSounds.find(pSoundFileName);
    if(itFind != mLoadedSounds.end())
    {
        itFind->second->AddRef();

        sound->Create(itFind->second, pIs3DSound);
    }
    else
    {
        ResourceImporter* importer = ResourceManager::Instance()->GetImporterForFile(pSoundFileName, SoundData::StaticClass());
        GD_ASSERT(importer);
        SoundData* soundData = Cast<SoundData>(importer->Import(pSoundFileName));
        mLoadedSounds[pSoundFileName] = soundData;

        sound->Create(soundData, pIs3DSound);
        sound->AddRef();
    }        

    sound->Init();
    return sound;
}
示例#4
0
Sound * Sound::Create(const String & fileName, eType type, int32 priority)
{
    if(TYPE_STATIC != type && TYPE_STREAMED != type && TYPE_MANAGED != type)
        return 0;
    
    Sound * sound = new Sound(fileName, type, priority);
    if(!sound->Init())
    {
        SafeRelease(sound);
    }
    return sound;
}
示例#5
0
Sound	* Sound::CreateMusic(const String & fileName, eType type, int32 priority /*= 0*/)
{
#if defined(__DAVAENGINE_IPHONE__)
    Sound * sound = new MusicIos(fileName);
    SoundSystem::Instance()->GroupMusic()->AddSound(sound);
    return sound;
#else
	Sound * sound = new Sound(fileName, type, priority);
	SoundSystem::Instance()->GroupMusic()->AddSound(sound);
	sound->Init();
	return sound;
#endif //#if defined(__DAVAENGINE_IPHONE__)
}
示例#6
0
Sound	* Sound::CreateFX(const String & fileName, eType type, int32 priority /*= 0*/)
{
    if(TYPE_STATIC != type && TYPE_STREAMED != type && TYPE_MANAGED != type)
        return 0;
    
	Sound * sound = new Sound(fileName, type, priority);
    if(!sound->Init())
    {
        SafeRelease(sound);
    }
    else
    {
        SoundSystem::Instance()->GroupFX()->AddSound(sound);
    }
	return sound;
}
示例#7
0
int main(int argc, char** argv){
	//ShowWindow(GetForegroundWindow(), SW_HIDE);
	Display display(WIDTH, HEIGHT, "OpenGL");
	if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){ std::cout << "ERROR: MixOpenAudio: " << Mix_GetError() << std::endl; }

	World world; Shader* shader = world.GetShader();
	Brush br(24, 6, 24, &world, "./res/tex/pxl_cuboid.jpg"); br.Move(-2, 0, -2);

	Brush c1(1, 0.5, 3, &world, "./res/tex/pxl_cuboid.jpg"); c1.Move(2, 0, 2);
	Brush c2(1, 1.0, 3, &world, "./res/tex/pxl_cuboid.jpg"); c2.Move(3, 0, 2);
	Brush c3(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c3.Move(6, 0.9, 2);
	Brush c4(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c4.Move(6, 1.1, 3.5);

	Brush box(1, 1, 1, &world, "./res/tex/pxl_cuboid.jpg"); box.Move(6, 0.5, 6);

	Player player(shader); display.SetPlayer(player);
	Camera cammy; cammy.Init(glm::vec3(0, 0, 0), 70.0f, 1600 / 900, 0.01f, 1000.0f);
	Ambient amb1; shader->AddAmbient(&amb1); amb1.m_range = 3; amb1.m_intensity = 0.2;
	Ambient amb2; shader->AddAmbient(&amb2); amb2.SetPosition(1, 1, 1);
	Ambient amb3; shader->AddAmbient(&amb3); amb3.SetPosition(15, 1, 10); amb3.SetColor(0.2, 0.5, 0.7);

	Prop prop(world.GetMesh("./res/models/cucco.obj"), world.GetTexture("./res/models/cucco.jpg"), shader); world.AddProp(&prop);
	Prop stone(world.GetMesh("./res/models/salesman.obj"), world.GetTexture("./res/models/salesman.jpg"), shader); world.AddProp(&stone); stone.Scale(0.01); stone.Teleport(0, -10, 0);
	Sound laugh; laugh.Init("./res/sounds/sale_laugh.wav", 0.7); laugh.Load();
	
	player.SetListener(Player_OnClick, OnClick);

	float count = 0.0f;
	while (!display.IsClosed()){
		display.Clear(0.1f, 0.3f, 0.8f, 1.0f);
		world.Draw(&player.GetCamera());
		player.DrawHUD();
		display.Update();

		laugh.Update(player.GetCamera().GetPos());

		if (count >= 2 * PI){ count = 0; }
		count += 0.05f;
		c4.Rotate(0, 1, 0);

		if (glm::distance(prop.position, player.GetCamera().GetPos()) >= 2){
			prop.velocity = (player.GetCamera().GetPos() - prop.position) / 64.0f;
			prop.velocity.y = 0;
			prop.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(prop.velocity)), 0);
		}
		else{
			prop.velocity *= 0;
		}
		prop.Rotate(0, sin(count) * PI / 360, 0);
		amb1.m_position = player.GetCamera().GetPos();

		if (player.mouse_buttons[0]){//Left Clicking
			player.mouse_buttons[0] = false;
			stone.Teleport(world.GetAimPoint(&player));
			stone.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(player.GetCamera().GetPos() - stone.position)), 0);
			laugh.pos = stone.position;
			laugh.Emit(player.GetCamera().GetPos());
		}

		world.Update();
		player.Update();
		world.IsCollide(&player);
		player.CommenceVelocity();
	}
	Mix_CloseAudio();
	Mix_Quit();
	return 0;
}
示例#8
0
Sound * Sound::Create(const String & fileName, eType type, int32 priority)
{
	Sound * sound = new Sound(fileName, type, priority);
	sound->Init();
	return sound;
}