Teo-CD
cad775f88e
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.
30 lines
577 B
C++
30 lines
577 B
C++
//
|
|
// Created by trotfunky on 27/05/19.
|
|
//
|
|
|
|
#ifndef RAYCASTING_PLAYER_H
|
|
#define RAYCASTING_PLAYER_H
|
|
|
|
#include <cmath>
|
|
|
|
static constexpr float deg_to_rad = 3.14159265/180;
|
|
|
|
class Player {
|
|
public:
|
|
Player(float x, float y, float alpha);
|
|
|
|
float x;
|
|
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);
|
|
};
|
|
|
|
|
|
#endif //RAYCASTING_PLAYER_H
|