A few tweaks to make the HP bar work constnantly, probably not the most efficient but it's good enough for now.

master
Zed A. Shaw 10 months ago
parent dfd59065f7
commit 1886c99920
  1. 2
      assets/enemies.json
  2. 4
      assets/items.json
  3. 3
      combat_ui.cpp
  4. 2
      gui_fsm.cpp
  5. 2
      lights.hpp

@ -8,7 +8,7 @@
}, },
{"_type": "Combat", "hp": 200, "max_hp": 200, "damage": 50, "dead": false}, {"_type": "Combat", "hp": 200, "max_hp": 200, "damage": 50, "dead": false},
{"_type": "Motion", "dx": 0, "dy": 0, "random": false}, {"_type": "Motion", "dx": 0, "dy": 0, "random": false},
{"_type": "LightSource", "strength": 40, "radius": 1.5}, {"_type": "LightSource", "strength": 45, "radius": 2.0},
{"_type": "EnemyConfig", "hearing_distance": 5}, {"_type": "EnemyConfig", "hearing_distance": 5},
{"_type": "Animation", "scale": 0.1, "simple": true, "frames": 10, "speed": 1.0} {"_type": "Animation", "scale": 0.1, "simple": true, "frames": 10, "speed": 1.0}
] ]

@ -54,7 +54,7 @@
"foreground": [24, 205, 210], "foreground": [24, 205, 210],
"background": [24, 205, 210] "background": [24, 205, 210]
}, },
{"_type": "LightSource", "strength": 60, "radius": 1.8}, {"_type": "LightSource", "strength": 50, "radius": 2.8},
{"_type": "Sprite", "name": "torch_pillar"}, {"_type": "Sprite", "name": "torch_pillar"},
{"_type": "Sound", "attack": "pickup", "death": "blank"} {"_type": "Sound", "attack": "pickup", "death": "blank"}
] ]
@ -69,7 +69,7 @@
"foreground": [255, 205, 189], "foreground": [255, 205, 189],
"background": [255, 205, 189] "background": [255, 205, 189]
}, },
{"_type": "Curative", "hp": 200}, {"_type": "Curative", "hp": 20},
{"_type": "Sprite", "name": "healing_potion_small"}, {"_type": "Sprite", "name": "healing_potion_small"},
{"_type": "Sound", "attack": "pickup", "death": "blank"} {"_type": "Sound", "attack": "pickup", "death": "blank"}
] ]

@ -41,11 +41,12 @@ namespace gui {
} }
void CombatUI::draw(sf::RenderWindow& window) { void CombatUI::draw(sf::RenderWindow& window) {
auto& player_combat = $level.world->get<components::Combat>($level.player);
set_damage(float(player_combat.hp) / float(player_combat.max_hp));
$gui.render(window); $gui.render(window);
} }
void CombatUI::set_damage(float percent) { void CombatUI::set_damage(float percent) {
fmt::println("combat ui sets damage: {}", percent);
auto& meter = $gui.world().get<Meter>($meter); auto& meter = $gui.world().get<Meter>($meter);
meter.percent = percent; meter.percent = percent;
} }

@ -319,8 +319,6 @@ namespace gui {
if(damage.enemy_did > 0) { if(damage.enemy_did > 0) {
$status_ui.log(fmt::format("Enemy HIT YOU for {} damage!", damage.enemy_did)); $status_ui.log(fmt::format("Enemy HIT YOU for {} damage!", damage.enemy_did));
auto player_combat = world.get<Combat>(player.entity);
$combat_ui.set_damage(float(player_combat.hp) / float(player_combat.max_hp));
} else { } else {
$status_ui.log("Enemy MISSED YOU."); $status_ui.log("Enemy MISSED YOU.");
} }

@ -11,7 +11,7 @@ namespace lighting {
using components::LightSource; using components::LightSource;
const int MIN = 20; const int MIN = 20;
const int MAX = 125; const int MAX = 135;
class LightRender { class LightRender {
public: public: