void play_sound(sf::Sound& sound, const SoundSample& sample, const PlaybackProperties& properties, bool looped)
 {
   sound.setBuffer(sample);
   sound.setPitch(properties.pitch);
   sound.setAttenuation(properties.attenuation);
   sound.setLoop(looped);
   sound.setRelativeToListener(properties.relative_to_listener);
   sound.setMinDistance(properties.min_distance);
   sound.setVolume(properties.volume * 100.0f);
   sound.play();
 }
예제 #2
0
파일: main.cpp 프로젝트: lupuchard/gamebase
// Program entry point
int main(int argc, char ** argv) {
	titleImg.loadFromFile("assets/title.png");

	sf::SoundBuffer sb;
	sb.loadFromFile("assets/avalanche.ogg");
	boulderSound.setBuffer(sb);
	boulderSound.setLoop(true);
	boulderSound.play();

	sf::SoundBuffer sb2;
	sb2.loadFromFile("assets/death.ogg");
	fallingSound.setBuffer(sb2);
	fallingSound.setRelativeToListener(true);

	sf::SoundBuffer sb3;
	sb3.loadFromFile("assets/jump.wav");
	jumpingSound.setBuffer(sb3);
	jumpingSound.setRelativeToListener(true);

	sf::SoundBuffer sb4;
	sb4.loadFromFile("assets/POL-flash-run-short.wav");
	musicSound.setBuffer(sb4);
	musicSound.setRelativeToListener(true);
	musicSound.setVolume(15.f);
	musicSound.setLoop(true);
	musicSound.play();

	sf::SoundBuffer sb5;
	sb5.loadFromFile("assets/footsteps.ogg");
	feetSound.setRelativeToListener(true);
	feetSound.setBuffer(sb5);
	feetSound.setLoop(true);
	feetSound.setVolume(50);
	feetSound.play();

	sf::SoundBuffer sb6;
	sb6.loadFromFile("assets/bump.ogg");
	bumpSound.setRelativeToListener(true);
	bumpSound.setBuffer(sb6);
	bumpSound.setVolume(40);

	sf::SoundBuffer sb7;
	sb7.loadFromFile("assets/gem.ogg");
	gemSound.setRelativeToListener(true);
	gemSound.setBuffer(sb7);
	gemSound.setVolume(60);

	sf::SoundBuffer sb8;
	sb8.loadFromFile("assets/Powerup3.wav");
	powerSound.setRelativeToListener(true);
	powerSound.setBuffer(sb8);
	powerSound.setVolume(80);

	sf::SoundBuffer sb9;
	sb9.loadFromFile("assets/alert.ogg");
	alertSound.setRelativeToListener(true);
	alertSound.setBuffer(sb9);
	//powerSound.setVolume(80);

    // Create the SFML window
	window.create(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "A Bolder Escape");

    while (window.isOpen()) {
		events();
		if (!menu) logic();
		render();
    }

    return 0;
}