-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (38 loc) · 1.39 KB
/
Copy pathmain.cpp
File metadata and controls
60 lines (38 loc) · 1.39 KB
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
#include "updateGraphics.h"
#include "visuals.h"
#include "cmath"
#include <numbers>
int main(){
TDT4102::AnimationWindow window{0,0,WINDOW_WIDTH, WINDOW_HEIGHT, "RayTrace"};
Player player;
Map map;
// Placing structures in map
map.placeWall(true, {30, 5}, 50, 'R');
map.placeRectangle({10, 70}, 20, 20, 'Y');
while (!window.should_close()){
window.next_frame();
updateGraphics(window, map, player);
if (window.is_key_down(KeyboardKey::P)){
player.changeDeg(1);
}
if (window.is_key_down(KeyboardKey::O)){
player.changeDeg(-1);
}
double rad = player.getDeg() * std::numbers::pi / 180.0 + VISUAL_SPAN * std::numbers::pi / 180 / 2;
// Center of view is in the midle of the span, therefore divide by two
if (window.is_key_down(KeyboardKey::W)){
player.changePos(std::cos(rad) / 5, std::sin(rad) / 5, map);
}
if (window.is_key_down(KeyboardKey::S)){
player.changePos(-std::cos(rad) / 5, -std::sin(rad) / 5, map);
}
if (window.is_key_down(KeyboardKey::D)){
player.changePos(-std::sin(rad) / 5, std::cos(rad) / 5, map);
}
if (window.is_key_down(KeyboardKey::A)){
player.changePos(std::sin(rad) / 5, -std::cos(rad) / 5, map);
}
window.wait_for(0.01);
}
return 0;
}