Refactored out main.cpp to be a separate gui and using an FSM to keep the turn based nature straight.

This commit is contained in:
Zed A. Shaw 2025-02-04 12:56:20 -05:00
parent 7228bdf210
commit 1d3a76e5ee
8 changed files with 300 additions and 260 deletions

67
gui.hpp Normal file
View file

@ -0,0 +1,67 @@
#pragma once
#include "raycaster.hpp"
#include <iostream>
#include <chrono>
#include <numeric>
#include <functional>
#include "constants.hpp"
#include "stats.hpp"
#include "levelmanager.hpp"
#include "components.hpp"
#include "camera.hpp"
#include <numbers>
#include "fsm.hpp"
namespace gui {
enum class State {
START,
MOVING,
ROTATING,
IDLE,
END
};
enum class Event {
STARTED,
TICK,
MOVE_FORWARD,
MOVE_BACK,
MOVE_LEFT,
MOVE_RIGHT,
ROTATE_LEFT,
ROTATE_RIGHT,
QUIT
};
class FSM : public DeadSimpleFSM<State, Event> {
public:
float $rotation = -30.0f;
Point $player{0,0};
LevelManager $levels;
sf::RenderWindow $window;
CameraLOL $camera;
sf::Font $font;
sf::Text $text;
Stats $stats;
TexturePack $textures;
Raycaster $rayview;
FSM();
void event(Event ev);
void START(Event );
void MOVING(Event );
void ROTATING(Event );
void IDLE(Event ev);
void END(Event ev);
void keyboard();
void draw_weapon();
void draw_gui();
void render();
void mouse();
Matrix generate_map();
bool active();
};
}