Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Space-Invaders/Header/Global/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ namespace Global
static const sf::String background_music_path;
static const sf::String button_click_sound_path;
static const sf::String bullet_fire_sound_path;
static const sf::String explosion_sound_path;
static const sf::String powerup_enabled_sound_path;
static const sf::String powerup_disabled_sound_path;

};
}
2 changes: 2 additions & 0 deletions Space-Invaders/Header/Sound/SoundService.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace Sound
sf::SoundBuffer buffer_powerup_enabled;
sf::SoundBuffer buffer_powerup_disabled;

sf::SoundBuffer buffer_explosion_sound;

void loadBackgroundMusicFromFile();
void loadSoundFromFile();

Expand Down
2 changes: 2 additions & 0 deletions Space-Invaders/Source/Global/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ namespace Global
const sf::String Config::powerup_enabled_sound_path = "assets/sounds/powerup_enabled.ogg";

const sf::String Config::powerup_disabled_sound_path = "assets/sounds/powerup_disabled.ogg";

const sf::String Config::explosion_sound_path = "assets/sounds/explosion.wav";
}
7 changes: 7 additions & 0 deletions Space-Invaders/Source/Sound/SoundService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace Sound
printf("Error loading background music file");
if (!buffer_powerup_disabled.loadFromFile(Config::powerup_disabled_sound_path))
printf("Error loading background music file");
if (!buffer_explosion_sound.loadFromFile(Config::explosion_sound_path))
printf("error loading bakground music file");
}

void SoundService::playSound(SoundType soundType)
Expand Down Expand Up @@ -54,6 +56,11 @@ namespace Sound
powerup_sound_effect.play();
break;

case SoundType::EXPLOSION:
sound_effect.setBuffer(buffer_explosion_sound);
sound_effect.play();
break;

default:
printf("Invalid sound type");
return;
Expand Down