-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRaycaster.h
68 lines (55 loc) · 1.64 KB
/
Raycaster.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <unordered_map>
#include <utility>
#include <cmath>
#include "Player.h"
#include "Map.h"
#include "Enums.h"
class Raycaster
{
private:
//rendering
SDL_Window* mainWindow;
SDL_Renderer* renderer;
SDL_Texture* windowTexture;
//map texture filenames to corresponding SDL textures (loop through game map in constructor)
std::unordered_map<std::string, SDL_Texture*> textureMap;
//user input
SDL_Event event;
//game logic
Player* player;
Map* map;
int windowWidth, windowHeight;
double focalLength;
double targetFPS;
double FPS;
double lastFPSUpdate;
double prevFrameTime;
double currFrameTime;
double elapsedFrameTime;
//game state info
bool done;
bool strafeLeft;
bool strafeRight;
bool turnLeft;
bool turnRight;
bool moveForward;
bool moveBackward;
public:
Raycaster(int windowWidth, int windowHeight);
void InitVideo(int windowWidth, int windowHeight);
void CastRays();
void RenderFrame();
void DrawVertLine(int x, int yStart, int yEnd, unsigned int color);
void DrawFloorAndCeiling(unsigned int ceilingColor, unsigned int floorColor);
void HandleEvents();
void Cleanup();
void RunGameLoop();
void DebugPrint();
void DoUpdates();
void LoadTextures();
void PlayerMove(MoveType move);
bool IsDoneRendering();
SDL_Texture* LoadTexture(std::string filename);
};