mirror of
https://github.com/Floriansylvain/whateversfml.git
synced 2026-08-19 11:43:22 +02:00
feat: raycasting part 1
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user