We can go down a level and there's a loading screen for it. The map and motion now matches the directions shown in the raycasting. There's now a compass that shows you the direction you're facing.

This commit is contained in:
Zed A. Shaw 2025-02-25 13:15:39 -05:00
parent e9accf14e6
commit 54fbf22b6d
17 changed files with 124 additions and 36 deletions

View file

@ -1,5 +1,6 @@
#include "main_ui.hpp"
#include "components.hpp"
#include "easings.hpp"
namespace gui {
using namespace components;
@ -43,13 +44,15 @@ namespace gui {
"sdev: {:>8.5}\n"
"min: {:>8.5}\n"
"max: {:>8.5}\n"
"count:{:<10}\n\n"
"count:{:<10}\n"
"level: {} size: {}x{}\n\n"
"dir: {:0.2},{:0.2}\n\n"
"VSync? {}\n"
"FR Limit: {}\n"
"Debug? {}\n\n",
player_combat.hp, $stats.mean(), $stats.stddev(), $stats.min,
$stats.max, $stats.n, $level.index, map->width(), map->height(),
$rayview.$dir_x, $rayview.$dir_y,
VSYNC, FRAME_LIMIT, DEBUG_BUILD);
$overlay_ui.update_text("top_left", stats);
@ -70,9 +73,13 @@ namespace gui {
$rayview.set_position(RAY_VIEW_X, RAY_VIEW_Y);
$rayview.position_camera($player.x + 0.5, $player.y + 0.5);
$overlay_ui.show_label("top", $compass[$compass_dir]);
auto st = textures::get("down_the_well");
st.sprite->setPosition({RAY_VIEW_X, RAY_VIEW_Y});
st.sprite->setScale({0.5, 0.5});
auto bounds = st.sprite->getLocalBounds();
st.sprite->setPosition({RAY_VIEW_X + bounds.size.x / 2,
RAY_VIEW_Y + bounds.size.y / 2});
st.sprite->setOrigin({bounds.size.x / 2, bounds.size.y / 2});
$overlay_ui.render();
}
@ -81,11 +88,18 @@ namespace gui {
$show_level = true;
}
void MainUI::draw() {
auto start = std::chrono::high_resolution_clock::now();
auto start = $stats.time_start();
if($show_level) {
auto time = $clock.getElapsedTime();
auto st = textures::get("down_the_well");
float tick = ease::in_out_back(ease::sine(time.asSeconds()));
float scale = std::lerp(1.0, 1.3, tick);
st.sprite->setScale({scale, scale});
$window.draw(*st.sprite);
$overlay_ui.show_label("middle", "INTO THE WELL YOU GO...");
} else {
@ -93,9 +107,7 @@ namespace gui {
$rayview.draw($window);
}
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration<double>(end - start);
$stats.sample(1/elapsed.count());
$stats.sample_time(start);
$overlay_ui.draw($window);
@ -125,6 +137,9 @@ namespace gui {
}
void MainUI::plan_rotate(int dir) {
// -1 is left, 1 is right
$compass_dir = ($compass_dir + dir) % $compass.size();
$overlay_ui.update_label("top", $compass[$compass_dir]);
$camera.plan_rotate($rayview, dir);
}
@ -151,9 +166,12 @@ 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);
if($show_level) {
$show_level = false;
$level.world->send<Events::GUI>(Events::GUI::STAIRS_DOWN, $level.player, {});
$overlay_ui.close_label("middle");
} else {
$overlay_ui.$gui.mouse(x, y);
}
}
}