Going into a well triggers a little 'loading screen' that's currently faked. Click on it to continue.
This commit is contained in:
parent
9d49c6a30b
commit
e9accf14e6
8 changed files with 35 additions and 6 deletions
|
@ -30,7 +30,8 @@
|
|||
"blood_splatter": "assets/blood_splatter-256.png",
|
||||
"trash_button": "assets/trash_button.png",
|
||||
"axe_ranger": "assets/axe_ranger-256.png",
|
||||
"hairy_spider": "assets/hairy_spider-256.png"
|
||||
"hairy_spider": "assets/hairy_spider-256.png",
|
||||
"down_the_well": "assets/down_the_well.jpg"
|
||||
},
|
||||
"enemy": {
|
||||
"HEARING_DISTANCE": 5
|
||||
|
|
BIN
assets/down_the_well.jpg
Normal file
BIN
assets/down_the_well.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 431 KiB |
|
@ -98,7 +98,9 @@ namespace guecs {
|
|||
});
|
||||
}
|
||||
|
||||
void UI::mouse(float x, float y) {
|
||||
bool UI::mouse(float x, float y) {
|
||||
int action_count = 0;
|
||||
|
||||
$world.query<lel::Cell, Clickable>([&](auto ent, auto& cell, auto &clicked) {
|
||||
if((x >= cell.x && x <= cell.x + cell.w) &&
|
||||
(y >= cell.y && y <= cell.y + cell.h))
|
||||
|
@ -108,8 +110,12 @@ namespace guecs {
|
|||
} else {
|
||||
clicked.action(ent, {});
|
||||
}
|
||||
|
||||
action_count++;
|
||||
}
|
||||
});
|
||||
|
||||
return action_count > 0;
|
||||
}
|
||||
|
||||
Clickable make_action(DinkyECS::World& target, Events::GUI event) {
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace guecs {
|
|||
|
||||
void init();
|
||||
void render(sf::RenderWindow& window);
|
||||
void mouse(float x, float y);
|
||||
bool mouse(float x, float y);
|
||||
|
||||
template <typename Comp>
|
||||
void set(DinkyECS::Entity ent, Comp val) {
|
||||
|
|
|
@ -162,6 +162,7 @@ namespace gui {
|
|||
dbc::log("Nothing to close.");
|
||||
break;
|
||||
case STAIRS_DOWN:
|
||||
$main_ui.show_level();
|
||||
state(State::NEXT_LEVEL);
|
||||
break;
|
||||
case STOP_COMBAT:
|
||||
|
@ -177,7 +178,7 @@ namespace gui {
|
|||
using enum Event;
|
||||
|
||||
switch(ev) {
|
||||
case TICK:
|
||||
case STAIRS_DOWN:
|
||||
next_level();
|
||||
state(State::IDLE);
|
||||
default:
|
||||
|
|
1
main.cpp
1
main.cpp
|
@ -13,6 +13,7 @@ int main() {
|
|||
|
||||
// ZED: need to sort out how to deal with this in the FSM
|
||||
if(main.in_state(gui::State::IDLE)
|
||||
|| main.in_state(gui::State::NEXT_LEVEL)
|
||||
|| main.in_state(gui::State::MAPPING)
|
||||
|| main.in_state(gui::State::IN_COMBAT))
|
||||
{
|
||||
|
|
22
main_ui.cpp
22
main_ui.cpp
|
@ -69,14 +69,29 @@ namespace gui {
|
|||
$rayview.init_shaders();
|
||||
$rayview.set_position(RAY_VIEW_X, RAY_VIEW_Y);
|
||||
$rayview.position_camera($player.x + 0.5, $player.y + 0.5);
|
||||
|
||||
auto st = textures::get("down_the_well");
|
||||
st.sprite->setPosition({RAY_VIEW_X, RAY_VIEW_Y});
|
||||
st.sprite->setScale({0.5, 0.5});
|
||||
|
||||
$overlay_ui.render();
|
||||
}
|
||||
|
||||
void MainUI::show_level() {
|
||||
$show_level = true;
|
||||
}
|
||||
|
||||
void MainUI::draw() {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if($needs_render) $rayview.render();
|
||||
$rayview.draw($window);
|
||||
if($show_level) {
|
||||
auto st = textures::get("down_the_well");
|
||||
$window.draw(*st.sprite);
|
||||
$overlay_ui.show_label("middle", "INTO THE WELL YOU GO...");
|
||||
} else {
|
||||
if($needs_render) $rayview.render();
|
||||
$rayview.draw($window);
|
||||
}
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto elapsed = std::chrono::duration<double>(end - start);
|
||||
|
@ -136,6 +151,9 @@ namespace gui {
|
|||
}
|
||||
|
||||
void MainUI::mouse(int x, int y) {
|
||||
$show_level = false;
|
||||
$level.world->send<Events::GUI>(Events::GUI::STAIRS_DOWN, $level.player, {});
|
||||
$overlay_ui.close_label("middle");
|
||||
$overlay_ui.$gui.mouse(x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace gui {
|
|||
|
||||
class MainUI {
|
||||
public:
|
||||
bool $show_level = false;
|
||||
bool $needs_render = true;
|
||||
Point $player{0,0};
|
||||
Stats $stats;
|
||||
|
@ -38,6 +39,7 @@ namespace gui {
|
|||
void draw();
|
||||
void dirty();
|
||||
|
||||
void show_level();
|
||||
void dead_entity(DinkyECS::Entity entity);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue