Reworked the gui to use GUECS now so lots of code soon to die.

This commit is contained in:
Zed A. Shaw 2025-04-22 03:08:43 -04:00
parent e78340a0cd
commit 70c2ce7d51
9 changed files with 97 additions and 38 deletions

View file

@ -33,14 +33,11 @@ std::array<sf::Color, 10> VALUES{
};
SFMLBackend::SFMLBackend(GameEngine &g)
: window(sf::VideoMode({X_DIM, Y_DIM}), "Turing's Tarpit"),
: window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Turing's Tarpit"),
game(g), current_face(textures::get("building"))
{
}
void SFMLBackend::Window_update() {
window.display();
}
sf::Color SFMLBackend::value(Value level) {
return VALUES.at(int(level));
@ -57,8 +54,8 @@ void SFMLBackend::handle_events() {
}
sf::Vector2f translate(int x, int y) {
float step_x = X_DIM / TEXT_SIZE;
float step_y = (Y_DIM - 12) / TEXT_SIZE;
float step_x = SCREEN_WIDTH / TEXT_SIZE;
float step_y = (SCREEN_HEIGHT - 12) / TEXT_SIZE;
sf::Vector2f position{step_x * x, step_y * y * 2};
@ -121,7 +118,6 @@ void SFMLBackend::update_entities() {
string time = fmt::format("{:%H:%M:%OS}", elapsed_time);
write_text(7, 14, time, 2.0f);
Window_update();
}
void SFMLBackend::change_face(const string& name) {
@ -150,8 +146,8 @@ void SFMLBackend::startup() {
window.setPosition({0,0});
window.setFramerateLimit(FPS);
window.setVerticalSyncEnabled(true);
window.setFramerateLimit(FRAME_LIMIT);
window.setVerticalSyncEnabled(VSYNC);
}
bool SFMLBackend::is_open() {