Need the hit.wav to be mono, but now we have a sound we can move around, just not sure how to place it based on the visuals.
This commit is contained in:
parent
9102bdc8ad
commit
4ed06b10b1
11 changed files with 144 additions and 41 deletions
|
@ -4,6 +4,7 @@
|
|||
#include <cmath>
|
||||
#include "rand.hpp"
|
||||
#include "collider.hpp"
|
||||
#include "sound.hpp"
|
||||
|
||||
using std::string;
|
||||
using namespace fmt;
|
||||
|
@ -90,6 +91,7 @@ void System::combat(DinkyECS::World &world, Player &player) {
|
|||
const auto& player_position = world.component<Position>(player.entity);
|
||||
auto& player_combat = world.component<Combat>(player.entity);
|
||||
auto& log = world.get<ActionLog>();
|
||||
auto& sounds = world.get<SoundManager>();
|
||||
|
||||
// this is guaranteed to not return the given position
|
||||
auto [found, nearby] = collider.neighbors(player_position.location);
|
||||
|
@ -101,6 +103,7 @@ void System::combat(DinkyECS::World &world, Player &player) {
|
|||
|
||||
if(player_dmg > 0) {
|
||||
log.log(format("You HIT for {} damage, HP left {}.", player_dmg, enemy_combat.hp));
|
||||
sounds.play("hit");
|
||||
} else {
|
||||
log.log("You missed! They're quick!");
|
||||
}
|
||||
|
@ -109,6 +112,7 @@ void System::combat(DinkyECS::World &world, Player &player) {
|
|||
int enemy_dmg = enemy_combat.fight(player_combat);
|
||||
|
||||
if(enemy_dmg > 0) {
|
||||
sounds.play("hit");
|
||||
log.log(format("Enemy HIT YOU for {} damage.", enemy_dmg));
|
||||
} else {
|
||||
log.log("Enemy MISSED, you dodged it.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue