Got some new sounds and camera shake came back but has a bug.

main
Zed A. Shaw 2 weeks ago
parent ed9d0de8e0
commit 113811bc84
  1. BIN
      assets/combat_enemy_hit.mp3
  2. BIN
      assets/combat_miss.mp3
  3. BIN
      assets/combat_player_hit.mp3
  4. BIN
      assets/hit.wav
  5. BIN
      assets/loot_gold.mp3
  6. 24
      gui.cpp
  7. 1
      gui.hpp
  8. 2
      meson.build
  9. 2
      status.txt
  10. 10
      tests/sound.cpp

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -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<Loot&>(data);
auto inventory = $world.get<Inventory>(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<int>(-10,10);
int y = Random::uniform<int>(-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();

@ -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();
};

@ -1,4 +1,4 @@
project('lcthw-utilities', 'cpp',
project('roguish', 'cpp',
default_options: [ 'cpp_std=c++20' ])
catch2 = dependency('catch2-with-main')

@ -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.

@ -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);
}

Loading…
Cancel
Save