1
0
Fork 0

World: Implement raycaster

Implement the basic raycaster, checking every block intersection and the block
linked to that position.
Split the screen uniformally along the width.
Add data needed for camera maths in the Player class
Specify constraints on the raycast parameters.

Render the screen using the raycasts.
Call the renderer in the main loop.
This commit is contained in:
Teo-CD 2024-01-21 22:03:04 +00:00
parent c6b09d668c
commit cad775f88e
4 changed files with 126 additions and 28 deletions

View file

@ -5,6 +5,9 @@
#ifndef RAYCASTING_PLAYER_H
#define RAYCASTING_PLAYER_H
#include <cmath>
static constexpr float deg_to_rad = 3.14159265/180;
class Player {
public:
@ -14,7 +17,10 @@ public:
float y;
float orientation;
/* View properties. */
float fov = 70;
float sensorSize = 0.035; /* 35mm, about equivalent to human eye ? */
float focalLength = sensorSize / (2*tanf((fov*deg_to_rad)/2));
void move(float dx, float dy);
void rotate(float alpha);