From 7c1f05c80181e3c1743f16dbb142cc2f15d52b2e Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 16 Feb 2025 19:27:57 -0500 Subject: [PATCH] Combat UI is alright but need to now make a few common widgets. --- assets/config.json | 6 +++--- assets/enemies.json | 2 +- combat_ui.cpp | 14 +++++++++++--- combat_ui.hpp | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/assets/config.json b/assets/config.json index 9b67a8f..af8773d 100644 --- a/assets/config.json +++ b/assets/config.json @@ -21,13 +21,13 @@ "blood_splatter": "assets/blood_splatter-256.png" }, "enemy": { - "HEARING_DISTANCE": 20 + "HEARING_DISTANCE": 5 }, "player": { }, "worldgen": { - "enemy_probability": 80, + "enemy_probability": 20, "empty_room_probability": 10, - "device_probability": 30 + "device_probability": 20 } } diff --git a/assets/enemies.json b/assets/enemies.json index 0fa8db5..f73e98e 100644 --- a/assets/enemies.json +++ b/assets/enemies.json @@ -34,7 +34,7 @@ }, {"_type": "Combat", "hp": 50, "max_hp": 50, "damage": 50, "dead": false}, {"_type": "Motion", "dx": 0, "dy": 0, "random": false}, - {"_type": "EnemyConfig", "hearing_distance": 10}, + {"_type": "EnemyConfig", "hearing_distance": 5}, {"_type": "Sprite", "name": "evil_eye"} ] }, diff --git a/combat_ui.cpp b/combat_ui.cpp index 948d3e0..e9a7ac0 100644 --- a/combat_ui.cpp +++ b/combat_ui.cpp @@ -23,8 +23,8 @@ namespace gui { sf::RectangleShape shape; shape.setPosition({float(cell.x + 3), float(cell.y + 3)}); shape.setSize({float(cell.w - 6), float(cell.h - 6)}); - shape.setFillColor({100, 100, 100}); - shape.setOutlineColor({200, 200, 200}); + shape.setFillColor(ColorValue::DARK_MID); + shape.setOutlineColor(ColorValue::MID); shape.setOutlineThickness(1); if(name.starts_with("button_")) { @@ -35,7 +35,15 @@ namespace gui { label.setPosition({float(label_cell.x), float(label_cell.y) - label_cell.h / 2}); $labels.push_back(label); } else if(name == "bar_hp") { - shape.setFillColor({50, 200, 50}); + shape.setFillColor({150, 30, 30}); + } else if(name == "label_hp") { + sf::Text label($font, "hp:"); + label.scale({0.8, 0.8}); + auto bounds = label.getGlobalBounds(); + auto label_cell = lel::center(bounds.size.x, bounds.size.y, cell); + // this stupid / 2 is because SFML renders from baseline rather than from the claimed bounding box + label.setPosition({float(label_cell.x), float(label_cell.y + bounds.size.y)}); + $labels.push_back(label); } $shapes.insert_or_assign(name, shape); diff --git a/combat_ui.hpp b/combat_ui.hpp index 277df45..be2a8f5 100644 --- a/combat_ui.hpp +++ b/combat_ui.hpp @@ -12,7 +12,7 @@ namespace gui { public: std::string $grid = "[*%(100,150)button_attack1 | *%(100,150)button_attack2 | *%(100,150)button_attack3 | *%(100,150)button_heal]" - "[*%.(200,50)bar_hp | _ | %.(100,50)bar_ap ]"; + "[ >.%(100,50)label_hp | *%.(200,50)bar_hp | _ ]"; lel::Parser $layout; GameLevel $level; sf::Font $font;