More cleanup of the raycaster, finally removed the window as a dependency but I went against making it an sf::Drawable since that had a lot of code quality problems.

This commit is contained in:
Zed A. Shaw 2025-02-04 22:52:04 -05:00
parent d6c09e111d
commit d0badedbd9
5 changed files with 25 additions and 74 deletions

13
gui.cpp
View file

@ -13,7 +13,7 @@ namespace gui {
$window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Zed's Raycaster Thing"),
$font{"./assets/text.otf"},
$text{$font},
$rayview($window, $textures, RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT)
$rayview($textures, RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT)
{
$window.setVerticalSyncEnabled(VSYNC);
$window.setFramerateLimit(FRAME_LIMIT);
@ -21,7 +21,6 @@ namespace gui {
$text.setPosition({10,10});
$textures.load_tiles();
$textures.load_sprites();
$rayview.init_shaders();
}
void FSM::event(Event ev) {
@ -132,13 +131,6 @@ namespace gui {
case KEY::R:
$stats.reset();
break;
case KEY::P:
if($rayview.$active_shader == nullptr) {
$rayview.$active_shader = &$rayview.$paused;
} else {
$rayview.$active_shader = nullptr;
}
break;
default:
break; // ignored
}
@ -182,7 +174,7 @@ namespace gui {
void FSM::render() {
auto start = std::chrono::high_resolution_clock::now();
$rayview.render();
$rayview.draw($window);
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration<double>(end - start);
$stats.sample(1/elapsed.count());
@ -194,7 +186,6 @@ namespace gui {
void FSM::mouse() {
if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) {
$rayview.$anim.play(false);
$rotation = -30.0f;
} else {
$rotation = -10.0f;