From 1886c9992008fcb1588189d94d72bb0bb6a6ec74 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 24 Feb 2025 12:05:54 -0500 Subject: [PATCH] A few tweaks to make the HP bar work constnantly, probably not the most efficient but it's good enough for now. --- assets/enemies.json | 2 +- assets/items.json | 4 ++-- combat_ui.cpp | 3 ++- gui_fsm.cpp | 2 -- lights.hpp | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/assets/enemies.json b/assets/enemies.json index aa32116..00fccda 100644 --- a/assets/enemies.json +++ b/assets/enemies.json @@ -8,7 +8,7 @@ }, {"_type": "Combat", "hp": 200, "max_hp": 200, "damage": 50, "dead": 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": "Animation", "scale": 0.1, "simple": true, "frames": 10, "speed": 1.0} ] diff --git a/assets/items.json b/assets/items.json index 364e135..599b39f 100644 --- a/assets/items.json +++ b/assets/items.json @@ -54,7 +54,7 @@ "foreground": [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": "Sound", "attack": "pickup", "death": "blank"} ] @@ -69,7 +69,7 @@ "foreground": [255, 205, 189], "background": [255, 205, 189] }, - {"_type": "Curative", "hp": 200}, + {"_type": "Curative", "hp": 20}, {"_type": "Sprite", "name": "healing_potion_small"}, {"_type": "Sound", "attack": "pickup", "death": "blank"} ] diff --git a/combat_ui.cpp b/combat_ui.cpp index 96a5ddc..13a493a 100644 --- a/combat_ui.cpp +++ b/combat_ui.cpp @@ -41,11 +41,12 @@ namespace gui { } void CombatUI::draw(sf::RenderWindow& window) { + auto& player_combat = $level.world->get($level.player); + set_damage(float(player_combat.hp) / float(player_combat.max_hp)); $gui.render(window); } void CombatUI::set_damage(float percent) { - fmt::println("combat ui sets damage: {}", percent); auto& meter = $gui.world().get($meter); meter.percent = percent; } diff --git a/gui_fsm.cpp b/gui_fsm.cpp index 7139a05..01b4b73 100644 --- a/gui_fsm.cpp +++ b/gui_fsm.cpp @@ -319,8 +319,6 @@ namespace gui { if(damage.enemy_did > 0) { $status_ui.log(fmt::format("Enemy HIT YOU for {} damage!", damage.enemy_did)); - auto player_combat = world.get(player.entity); - $combat_ui.set_damage(float(player_combat.hp) / float(player_combat.max_hp)); } else { $status_ui.log("Enemy MISSED YOU."); } diff --git a/lights.hpp b/lights.hpp index 8da0bdd..3b5f3df 100644 --- a/lights.hpp +++ b/lights.hpp @@ -11,7 +11,7 @@ namespace lighting { using components::LightSource; const int MIN = 20; - const int MAX = 125; + const int MAX = 135; class LightRender { public: