Combat UI is alright but need to now make a few common widgets.
This commit is contained in:
parent
cfe56bbf99
commit
7c1f05c801
4 changed files with 16 additions and 8 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue