-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircle.cpp
More file actions
125 lines (93 loc) · 2.88 KB
/
circle.cpp
File metadata and controls
125 lines (93 loc) · 2.88 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "cppboost.cpp"
#include <cmath>
#define torad 3.14159/180
#define todeg 180/3.14159
#define angz (int(angle)%359)
int main(){
int plX = 8, plY = 8;
float rX = 0, rY = 0;
float angle = 0;
int raytr = 0;
while(1){
gotoxy(0,0);
string world[15]={
"111111111111111",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"111111111111111",
};
char inp = getch();
switch(inp){
//case 'q': playerangle += 90.0; type *= -1; break;
//case 'e': playerangle -= 90.0; type *= -1; break;
case 'a': plX -= 1; break;
case 'd': plX += 1; break;
case 'w': plY -= 1; break;
case 's': plY += 1; break;
case ' ': raytr = 1; gotoxy(20,19); say "Angle: "; input angle; break;
}
world[plY][plX] = '9';
if(raytr == 1){
int hit = 0;
int type = 1;
float dsX = 0, dsY = 0;
rX = plX, rY = plY;
if(angz < 45) {type = 1;}
else if(angz >= 45 && angz <= 135) {type = 2;}
else if(angz >= 136 && angz <= 225) {type = 1;}
else if(angz >= 226 && angz <= 315) {type = 2;}
else if(angz >= 316) {type = 1;}
while(hit == 0){
angle -= 22.5;
string world[15]={
"111111111111111",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"1 1",
"111111111111111",
};
world[plY][plX] = '9';
rX += -sin(angle * torad);
rY += -cos(angle * torad);
((type == 1) ? dsX:dsY) = abs(plX - rX);
((type == 1) ? dsY:dsX) = abs(plY - rY);
gotoxy(20,20); printf("Side from: %2.2f | Away from you: %2.2f",dsX, dsY);
if (world[int(rY)][int(rX)] == '1') hit = 1;
world[int(rY)][int(rX)] = '2';
gotoxy(0,0);
for(int i = 0; i < 15; i++){
qprint(world[i]);
say endl;
}
Sleep(50);
}
raytr = 0;
}
gotoxy(0,0);
for(int i = 0; i < 15; i++){
qprint(world[i]);
say endl;
}
}
}