1
0
Fork 0
Toy-Raytracer/Player.h
Teo-CD b47052aa4d Implement moving the player
Player: Add rotation and linear speeds, as well as their current state.
Player: Allow to move in the local coordinates and compute
    world-speed equivalent.
Player: Update movement axis while rotating.

World: Add a function to advance a step.
Main: Handle key events, add world step in the main loop.
2024-01-21 22:11:46 +00:00

39 lines
788 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;
float moveSpeed = 5;
float rotationSpeed = 180;
float currentMoveSpeedX = 0;
float currentMoveSpeedY = 0;
float currentRotationSpeed = 0;
/* 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);
void updateSpeed(float localX, float localY);
};
#endif //RAYCASTING_PLAYER_H