This converts it to SFML 3.0 but the build only runs on Windows at the moment.

This commit is contained in:
Zed A. Shaw 2025-01-17 15:10:03 -05:00
parent cdbd83ded7
commit 105c974f1c
7 changed files with 62 additions and 630 deletions

View file

@ -24,10 +24,15 @@ Matrix MAP{
{1,1,1,1,1,1,1,1,1}
};
int main() {
using KB = sf::Keyboard;
void draw_gui(sf::RenderWindow &window) {
sf::RectangleShape rect({SCREEN_WIDTH - RAY_VIEW_WIDTH, 300});
rect.setPosition({0,0});
rect.setFillColor({100, 100, 100});
window.draw(rect);
}
sf::RenderWindow window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Zed's Ray Caster Game Thing");
int main() {
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Zed's Ray Caster Game Thing");
//ZED this should set with a function
float player_x = matrix::width(MAP) / 2;
@ -40,30 +45,29 @@ int main() {
double moveSpeed = 0.1;
double rotSpeed = 0.1;
const auto onClose = [&window](const sf::Event::Closed&)
{
window.close();
};
while(window.isOpen()) {
rayview.render();
// DRAW GUI
draw_gui(window);
window.display();
if(KB::isKeyPressed(KB::W)) {
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) {
rayview.run(moveSpeed, 1);
} else if(KB::isKeyPressed(KB::S)) {
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S)) {
rayview.run(moveSpeed, -1);
}
if(KB::isKeyPressed(KB::D)) {
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D)) {
rayview.rotate(rotSpeed, -1);
} else if(KB::isKeyPressed(KB::A)) {
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) {
rayview.rotate(rotSpeed, 1);
}
sf::Event event;
while(window.pollEvent(event)) {
if(event.type == sf::Event::Closed) {
window.close();
}
}
window.handleEvents(onClose);
}
return 0;