diff --git a/assets/combat_enemy_hit.mp3 b/assets/combat_enemy_hit.mp3 new file mode 100644 index 0000000..a888f17 Binary files /dev/null and b/assets/combat_enemy_hit.mp3 differ diff --git a/assets/combat_miss.mp3 b/assets/combat_miss.mp3 new file mode 100644 index 0000000..c466c1f Binary files /dev/null and b/assets/combat_miss.mp3 differ diff --git a/assets/combat_player_hit.mp3 b/assets/combat_player_hit.mp3 new file mode 100644 index 0000000..76e6c4b Binary files /dev/null and b/assets/combat_player_hit.mp3 differ diff --git a/assets/hit.wav b/assets/hit.wav deleted file mode 100644 index 83af3f4..0000000 Binary files a/assets/hit.wav and /dev/null differ diff --git a/assets/loot_gold.mp3 b/assets/loot_gold.mp3 new file mode 100644 index 0000000..1caab86 Binary files /dev/null and b/assets/loot_gold.mp3 differ diff --git a/gui.cpp b/gui.cpp index 7f57121..79e2399 100644 --- a/gui.cpp +++ b/gui.cpp @@ -39,7 +39,11 @@ GUI::GUI(DinkyECS::World &world, Map& game_map) : $renderer($canvas, $map_screen, $screen) { // this needs a config file soon - $sounds.load("hit", "hit.wav"); + $sounds.load("ambient", "ambient_sound.mp3"); + $sounds.load("loot_gold", "loot_gold.mp3"); + $sounds.load("combat_player_hit", "combat_player_hit.mp3"); + $sounds.load("combat_enemy_hit", "combat_enemy_hit.mp3"); + $sounds.load("combat_miss", "combat_miss.flac"); resize_map(BASE_MAP_FONT_SIZE); } @@ -114,21 +118,24 @@ void GUI::handle_world_events() { if(damage.enemy_did > 0) { $log.log(format("Enemy HIT YOU for {} damage!", damage.enemy_did)); $log.log(format("-- Enemy has {} HP left.", enemy_combat.hp)); - $sounds.play("hit"); + $sounds.play("combat_enemy_hit"); + shake(); } else { $log.log("Enemy MISSED YOU."); } if(damage.player_did > 0) { $log.log(format("You HIT enemy for {} damage!", damage.player_did)); - $sounds.play("hit"); + $sounds.play("combat_player_hit"); } else { + $sounds.play("combat_miss"); $log.log("You MISSED the enemy."); } } break; case eGUI::LOOT: { auto &loot = std::any_cast(data); auto inventory = $world.get(player.entity); + $sounds.play("loot_gold"); $log.log(format("You found {} gold. You have {} now.", loot.amount, inventory.gold)); } @@ -185,6 +192,16 @@ void GUI::run_systems() { System::death($world); } +void GUI::shake() { + for(int i = 0; i < 10; ++i) { + int x = Random::uniform(-10,10); + int y = Random::uniform(-10,10); + // add x/y back to draw screen + $renderer.draw_screen(true, x, y); + std::this_thread::sleep_for(1ms); + } +} + void GUI::render_scene() { $screen.Clear(); $map_screen.Clear(); @@ -194,6 +211,7 @@ void GUI::render_scene() { } int GUI::main() { + // $sounds.play("ambient"); create_renderer(); run_systems(); diff --git a/gui.hpp b/gui.hpp index b7bb703..b6880be 100644 --- a/gui.hpp +++ b/gui.hpp @@ -59,6 +59,7 @@ public: void draw_screen(bool clear=true, float map_off_x=0.0f, float map_off_y=0.0f); void run_systems(); void save_world(); + void shake(); int main(); }; diff --git a/meson.build b/meson.build index 19a4486..57d6711 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('lcthw-utilities', 'cpp', +project('roguish', 'cpp', default_options: [ 'cpp_std=c++20' ]) catch2 = dependency('catch2-with-main') diff --git a/status.txt b/status.txt index 0ce0bb9..6ff4992 100644 --- a/status.txt +++ b/status.txt @@ -2,6 +2,8 @@ NOTES: TODO: +* draw_screen doesn't do x axis offset render +* Can std::any be defaulted to a noop in the events? * Save file isn't saving gold. * Inventory needs to be better, but need some kinds of "weapons" or other loot to get and not just gold. * Run the ansi_parser on the whole UI so I can use colors and other glyphs. diff --git a/tests/sound.cpp b/tests/sound.cpp index a39e4de..8d65979 100644 --- a/tests/sound.cpp +++ b/tests/sound.cpp @@ -12,10 +12,10 @@ TEST_CASE("confirm basic functionality", "[sounds]") { SoundManager sounds("./assets"); - REQUIRE_THROWS(sounds.load("hit", "badfileDOESNOTEXIST.wav")); - REQUIRE_THROWS(sounds.play("hit")); + REQUIRE_THROWS(sounds.load("bad", "badfileDOESNOTEXIST.wav")); + REQUIRE_THROWS(sounds.play("bad")); - sounds.load("hit", "hit.wav"); - sounds.play("hit"); - sounds.playAt("hit", 1, 1, 1); + sounds.load("combat_miss", "combat_miss.flac"); + sounds.play("combat_miss"); + sounds.playAt("combat_miss", 1, 1, 1); }