A few tweaks to make the HP bar work constnantly, probably not the most efficient but it's good enough for now.
This commit is contained in:
parent
dfd59065f7
commit
1886c99920
5 changed files with 6 additions and 7 deletions
|
@ -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}
|
||||
]
|
||||
|
|
|
@ -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"}
|
||||
]
|
||||
|
|
|
@ -41,11 +41,12 @@ namespace gui {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void CombatUI::set_damage(float percent) {
|
||||
fmt::println("combat ui sets damage: {}", percent);
|
||||
auto& meter = $gui.world().get<Meter>($meter);
|
||||
meter.percent = percent;
|
||||
}
|
||||
|
|
|
@ -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<Combat>(player.entity);
|
||||
$combat_ui.set_damage(float(player_combat.hp) / float(player_combat.max_hp));
|
||||
} else {
|
||||
$status_ui.log("Enemy MISSED YOU.");
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace lighting {
|
|||
using components::LightSource;
|
||||
|
||||
const int MIN = 20;
|
||||
const int MAX = 125;
|
||||
const int MAX = 135;
|
||||
|
||||
class LightRender {
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue