feat: raycasting part 1

This commit is contained in:
Floriansylvain
2025-12-28 05:35:35 +01:00
parent 62655038f3
commit 4402ec9159
4 changed files with 101 additions and 13 deletions
+22
View File
@@ -2,6 +2,10 @@
#define GAME_HPP
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/PrimitiveType.hpp>
#include <SFML/Graphics/VertexArray.hpp>
#include <SFML/Graphics/VertexBuffer.hpp>
#include <SFML/System/Vector2.hpp>
#include "DebugUI.hpp"
#include "GridLines.hpp"
@@ -14,6 +18,20 @@ constexpr int HEIGHT = 1080;
constexpr int DEBUG_REFRESH_RATE_IN_MS = 250;
constexpr float ASPECT = 16.f / 9.f;
struct Ray {
sf::Vector2f origin;
sf::Vector2f direction;
float angle;
Ray(sf::Vector2f origin, sf::Vector2f target) {
this->origin = origin;
this->direction = target - origin;
angle = direction.angleTo(origin).asDegrees();
};
Ray(float angle, float length) {}; // TODO
};
class Game {
public:
Game();
@@ -28,6 +46,10 @@ private:
GridLines gridLines;
Walls walls;
sf::VertexArray rayVertices;
float intersects(Ray ray, Wall wall);
void onResize();
void processEvents();
void update(double dt);