-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaze.cpp
More file actions
782 lines (667 loc) · 38.8 KB
/
maze.cpp
File metadata and controls
782 lines (667 loc) · 38.8 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
#include "globals.h"
#include "maze.h"
#include "mbed.h"
#include "N5110.h"
#include "Joystick.h"
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define PI 3.14159265358979323846
#define NUM_RAYS 84 // Number of rays to cast for the maze
float y = 24; //position of player
float x = 42;
float direction = 0.0; //initialise direction of the point to 0 degrees (facing up)
int mazeSpeed = 1; //speed of the point
//float maze_speed = 0.5; //speed of the point
bool firstPerson = true;
bool goelReached = false;
float FOV = 100 * (PI / 180);
bool hitVertical = false;
bool darkMode = false;
bool darkness = false;
int texture;
int tileX, tileY;
int level = 1;
const int MAP_WIDTH = 15;
const int MAP_HEIGHT = 9;
const int TILE_SIZE = 6; // pixels per tile for display (top down view)
int map[MAP_HEIGHT][MAP_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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
//pointers for vertical and horizontal walls
const int (*wallH)[16] = wall2;
const int (*wallV)[16] = wall3;
void maze(){
/*
game that makes a 3d raycasted maze
*/
generateMaze(map); //generate the maze
printMaze(map); //print the maze to the consol for debugging
printf("\n\n");
x = 9; //starting posistion of the player
y = 9;
while (1) {
lcd.clear();
tileX = (int)(x)/6; //calculate the x coordinate of the maze tile
tileY = (int)(y)/6; //calculate the y
draw3Drays(); //draws the rays from the point to the walls of the maze
if(joystick.get_direction() == N){
moveForward(x, y);
//printf(" Direction: N\n");
}else if(joystick.get_direction() == S){
moveBackward(x, y);
//printf(" Direction: S\n");
}else if(joystick.get_direction() == E){
direction += 5; //increment the direction of the point by 5 degrees
//printf(" Direction: E\n");
}else if(joystick.get_direction() == W){
direction -= 5;
//printf(" Direction: W\n");
}
else {
//printf(" Direction: Centre\n");
}
if (direction < 0) direction += 360;
if (direction > 360) direction -= 360;
if (g_buttonA_flag) { // check if menu button pressed
ThisThread::sleep_for(500ms);
g_buttonA_flag = 0;
printf(" exiting maze \n");
break;
}
if (g_joystick_flag) { // check if menu button pressed
printf("joystick pressed tile: %d, %d type: %d texture %d \n", tileX, tileY, map[tileX][tileY], texture);
ThisThread::sleep_for(500ms);
g_joystick_flag = 0;
firstPerson = !firstPerson; //toggle first person view
}
if (goelReached == true) { //if goal has been reached
printf("goal reached\n");
goelReached = false;
nextLevel(); //go to next level
}
collisionDetection(x, y, direction, mazeSpeed); //check for collision with walls also checks for goal reached
lcd.refresh();
ThisThread::sleep_for(30ms);
}
}
void moveForward(float &x, float &y) {
// Calculate the new position based on the current direction and mazeSpeed
x += mazeSpeed * cos(direction * PI / 180.0); // Convert degrees to radians
y += mazeSpeed * sin(direction * PI / 180.0); // Invert y-axis for LCD coordinate system
}
void moveBackward(float &x, float &y) {
// Calculate the new position based on the current direction and mazeSpeed
x -= mazeSpeed * cos(direction * PI / 180.0); // Convert degrees to radians
y -= mazeSpeed * sin(direction * PI / 180.0); // Invert y-axis for LCD coordinate system
}
float dist(float ax, float ay, float bx, float by, float ang) {
// Calculate the distance from the current position to the target position
return (sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay)));
}
void draw3Drays() {
// KEY
int r,mx,my,mp,dof; // r = ray; mx,my = mapx,y; dof = depth of field
float rx,ry,ra,xo,yo; // rx,ry = ray x,y position; ra = ray angle; xo,yo = x,y offset
ra = direction * PI / 180 - FOV / 2; // start at leftmost angle of FOV
for (r=0; r<NUM_RAYS;r++)
{
dof = 0; //reset the depth of field
float aTan = -1/tan(ra); //calculate the tangent of the angle
float distH = 100000000; float hx=x, hy=y; //initialise the distance to a large number
//////// horizontal ray checking
// Looking up
if (ra > PI) {
hy = ((int)(y / TILE_SIZE)) * TILE_SIZE - 0.0001;
hx = (y - hy) * aTan + x;
yo = -TILE_SIZE;
xo = -yo * aTan;
}
// Looking down
else if (ra < PI) {
hy = ((int)(y / TILE_SIZE)) * TILE_SIZE + TILE_SIZE;
hx = (y - hy) * aTan + x;
yo = TILE_SIZE;
xo = -yo * aTan;
}
if (ra == 0 || ra == PI) { hx=x; hy=y; dof=8; } //ray is facing left or right
while (dof<14) //loop until the ray hits a wall or reaches the maximum depth of field
{
mx = (int)(hx)/6; //calculate the x coordinate of the maze tile
my = (int)(hy)/6; //calculate the y coordinate of the maze tile
mp = my*MAP_WIDTH+mx; //calculate the index of the maze tile in the map array
if (mx < 0 || mx >= MAP_WIDTH || my < 0 || my >= MAP_HEIGHT) {
dof = 14;
break;
}
if (map[my][mx] > 0) {
//printf("Hit wall at rx: %.2f, ry: %.2f\n", rx, ry);
texture = map[my][mx]; //set the texture to the wall texture hit
distH = dist(x, y, hx, hy, ra); //calculate the distance to the wall
break;
}
else { hx += xo; hy += yo; dof++; } //move to next tile
}
//////// vertical ray checking
dof = 0; //reset the depth of field
aTan = -tan(ra); //calculate the tangent of the angle
float distV = 100000000; float vx=x, vy=y; //initialise the distance to a large number
// Looking right
if (ra > PI/2 && ra < 3*PI/2) {
vx = ((int)(x / TILE_SIZE)) * TILE_SIZE - 0.0001;
vy = (x - vx) * aTan + y;
xo = -TILE_SIZE;
yo = -xo * aTan;
}
// Looking left
else if (ra < PI/2 || ra > 3*PI/2) {
vx = ((int)(x / TILE_SIZE)) * TILE_SIZE + TILE_SIZE;
vy = (x - vx) * aTan + y;
xo = TILE_SIZE;
yo = -xo * aTan;
}
if (ra == 3*PI/2 || ra == PI/2) { vx=x; vy=y; dof=8; } //ray is facing up or down
while (dof<14) //loop until the ray hits a wall or reaches the maximum depth of field
{
mx = (int)(vx)/6; //calculate the x coordinate of the maze tile
my = (int)(vy)/6; //calculate the y coordinate of the maze tile
mp = my*MAP_WIDTH+mx; //calculate the index of the maze tile in the map array
if (mx < 0 || mx >= MAP_WIDTH || my < 0 || my >= MAP_HEIGHT) {
//dof = 14;
break;
}
if (map[my][mx] > 0) {
//printf("Hit wall at vx: %.2f, vy: %.2f\n", vx, vy);
texture = map[my][mx];
distV = dist(x, y, vx, vy, ra); //calculate the distance to the wall
break;
}
else { vx += xo; vy += yo; dof++; } //move to next tile
}
if (distH < distV) { //if the horizontal distance is less than the vertical distance
rx = hx; ry = hy; //set the intersection point to the horizontal intersection point
hitVertical = false;
distV = distH; //set the vertical distance to the horizontal distance
}
if (distV < distH) { //if the vertical distance is less than the horizontal distance
rx = vx; ry = vy; //set the intersection point to the vertical intersection point
hitVertical = true;
distH = distV; //set the horizontal distance to the vertical distance
}
if (!firstPerson) { //display the map if first person mode is disabled
drawMap();
}
else // =====if first person mode is enabled=====
{
float ca = (direction * PI / 180) - ra; // Calculate the angle difference
if (ca < 0) ca += 2*PI; // Wrap around to 0 degrees
if (ca > 2*PI) ca -= 2*PI; // Wrap around to 0 degrees
ca = cos(ca);
distV = distV * ca; // Adjust the distance based on the angle difference
int lineHeight = (int)(TILE_SIZE / distV * 27); // Adjust height based on distance
int drawStart = (48 - lineHeight) / 2; // Center the wall slice vertically
int drawEnd = drawStart + lineHeight;
float ty_step = 16.0f / (drawEnd - drawStart);
float ty_off=0;
if (lineHeight>48) { ty_off=(lineHeight-48)/2; lineHeight = 48;}
if (drawStart < 0) drawStart = 0;
if (drawEnd >= 48) drawEnd = 47;
float wallHeight = 16; // Height of the wall slice
float ty = ty_off*ty_step; // Texture Y coordinate
float tx;
if (hitVertical) {
tx = fmod(ry, 6.0f) / 6.0f * 16.0f;
} else {
tx = fmod(rx, 6.0f) / 6.0f * 16.0f;
}
// Step size for texture Y coordinate
for (int i = drawStart; i < drawEnd; i++) {
int color = 0;
if(texture == 1) {
if (hitVertical) {
color = wallV[(int)ty][(int)tx];
} else {
color = wallH[(int)ty][(int)tx];
}
}
else if(texture == 2) {
color = door[(int)ty][(int)tx];
}
lcd.setPixel(r, i, color); // Set the pixel color based on the wall texture
ty += ty_step; // Increment the texture Y coordinate
}
//draw =========floors and ceilings===========
//note: only draws textures in one direction
float textureSizeModifier = 1.0; // smaller numbers means bigger texture
for (int i = 0; i < drawStart; i++) { // cieling
float dy = i - 24;
// prevents division by zero
if (fabs(dy) < 0.01f) dy = 0.01f;
// Correct fish-eye distortion
float raFix = cos((direction * PI / 180.0f) - ra);
float projectionPlane = (48.0f / 2.0f) / tanf(FOV * 0.5f);
float distance = (6 * projectionPlane) / (dy * raFix);
// position of the point we are sampling
float floorX = x - cos(ra) * distance;
float floorY = y - sin(ra) * distance;
// Texture coordinates (16x16 texture)
int tx = ((int)( textureSizeModifier * floorX * (16.0f / TILE_SIZE))) % 16;
int ty = ((int)( textureSizeModifier * floorY * (16.0f / TILE_SIZE))) % 16;
// Safety clamp to keep in bounds
if (tx < 0) tx += 16;
if (ty < 0) ty += 16;
int color = ceiling[ty][tx]; //swap the array for a different texture
lcd.setPixel(r, i, color);
}
for (int i = drawEnd; i < 48; i++) { // ===Floor=== identical to ceiling code except swapped the sign before cos and sig so it moves the correct way
float dy = i - 24;
if (fabs(dy) < 0.01f) dy = 0.01f;
float raFix = cos((direction * PI / 180.0f) - ra);
float projectionPlane = (48.0f / 2.0f) / tanf(FOV * 0.5f);
float distance = (6 * projectionPlane) / (dy * raFix);
float floorX = x + cos(ra) * distance;
float floorY = y + sin(ra) * distance;
int tx = ((int)( textureSizeModifier * floorX * (16.0f / TILE_SIZE))) % 16;
int ty = ((int)( textureSizeModifier * floorY * (16.0f / TILE_SIZE))) % 16;
if (tx < 0) tx += 16;
if (ty < 0) ty += 16;
int color = ceiling[ty][tx];
lcd.setPixel(r, i, color);
}
lcd.drawRect(0, 0, 84, 48, FILL_TRANSPARENT); // adds a screen border cause it looks good
}
ra += FOV / NUM_RAYS; //increment the angle of the ray
if (ra < 0) ra += 2*PI; //wrap the angle
if (ra > 2*PI) ra -= 2*PI;
}
// ================= flashlight / dark mode ===================
if (darkMode) {
static Timer darknessTimer;
static bool timerStarted = false;
if (!timerStarted) {
darknessTimer.start();
timerStarted = true;
}
if (darknessTimer.elapsed_time() > 2s && !darkness) {
darknessTimer.reset();
darkness = !darkness;
timerStarted = false;
}
if (darknessTimer.elapsed_time() > 5s && darkness) {
darknessTimer.reset();
darkness = !darkness;
timerStarted = false;
}
if (darkness) {
for (int i = 0; i < 4032; i++) {
if (flashlight[i] == 1) {
int xDark = i % 84;
int yDark = i / 84;
lcd.setPixel(xDark, yDark, FILL_BLACK);
}
}
}
else {
lcd.drawRect(0, 0, 84, 48, FILL_BLACK);
}
}//buttonDOWN.read() || buttonUP.read()
}
void drawMap() {
for (int y = 0; y < MAP_HEIGHT; y++) {
for (int x = 0; x < MAP_WIDTH; x++) {
int x0 = x * TILE_SIZE;
int y0 = y * TILE_SIZE;
if (map[y][x] == 1) {
lcd.drawRect(x0, y0, TILE_SIZE, TILE_SIZE, FILL_BLACK);
} else {
//lcd.drawRect(x0, y0, TILE_SIZE, TILE_SIZE, FILL_TRANSPARENT);
}
}
}
lcd.drawRect(x,y,2,2,FILL_BLACK); //draws point at position (x,y)
}
void collisionDetection(float &x, float &y, float direction, float mazeSpeed) {
float lookAhead = 0.5f;
// === FRONT COLLISION ===
float nextFrontX = x + lookAhead * cos(direction * PI / 180.0f);
float nextFrontY = y - lookAhead * sin(direction * PI / 180.0f);
int tileFrontX = int(nextFrontX / TILE_SIZE);
int tileFrontY = int(y / TILE_SIZE);
if (map[tileFrontY][tileFrontX] == 1) {
x -= mazeSpeed * cos(direction * PI / 180.0f);
printf("collided with wall \n");
}
tileFrontX = int(x / TILE_SIZE);
tileFrontY = int(nextFrontY / TILE_SIZE);
if (map[tileFrontY][tileFrontX] == 1) {
y += mazeSpeed * sin(direction * PI / 180.0f);
printf("collided with wall \n");
}
if (map[tileFrontY][tileFrontX] == 2) {
printf("collided with goal \n");
goelReached = true;
}
// === BACK COLLISION ===
float nextBackX = x - lookAhead * cos(direction * PI / 180.0f);
float nextBackY = y + lookAhead * sin(direction * PI / 180.0f);
int tileBackX = int(nextBackX / TILE_SIZE);
int tileBackY = int(y / TILE_SIZE);
if (map[tileBackY][tileBackX] == 1) {
x += mazeSpeed * cos(direction * PI / 180.0f);
}
tileBackX = int(x / TILE_SIZE);
tileBackY = int(nextBackY / TILE_SIZE);
if (map[tileBackY][tileBackX] == 1) {
y -= mazeSpeed * sin(direction * PI / 180.0f);
}
}
void generateMaze(int maze[8][15]) {
// Initialize all cells as walls
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 14; x++) {
maze[y][x] = 1; // wall
}
}
// Recursive backtracking to carve the maze
auto carve = [&](int x, int y, auto&& carve_ref) -> void {
const int dx[] = { 0, 0, -2, 2 }; // N S W E
const int dy[] = { -2, 2, 0, 0 };
std::vector<int> dir = { 0, 1, 2, 3};
std::random_shuffle(dir.begin(), dir.end());
for (int i : dir) {
int nx = x + dx[i];
int ny = y + dy[i];
if (ny > 0 && ny < 8 - 1 && nx > 0 && nx < 14 - 1 && maze[ny][nx] == 1) {
maze[ny][nx] = 0; // jump point
maze[y + dy[i] / 2][x + dx[i] / 2] = 0; // break wall between jump point
carve_ref(nx, ny, carve_ref);
}
}
};
// Start point
maze[1][1] = 0;
carve(1, 1, carve);
// Set goal: farthest path cell (bottom-right corner if possible)
for (int y = 8 - 2; y > 0; y--) {
for (int x = 14 - 2; x > 0; x--) {
if (maze[y][x] == 0) {
maze[y][x] = 0; // goal
maze[y][x+1] = 2; //exit
return;
}
}
}
}
void printMaze(int maze[8][15]) {
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 14; x++) {
printf("%d ", maze[y][x]);
}
printf("\n");
}
}
void nextLevel() {
// Function to generate the next level of the maze
// This function can be called when the player reaches the goal
lcd.clear();
lcd.drawRect(0, 0, 84, 48, FILL_TRANSPARENT); // Draw screen border
char buffer[32];
level++; // Increment the level
sprintf(buffer, "Level: %d", level);
lcd.printString("LEVEL COMPLETE", 1, 2);
lcd.printString(buffer, 1, 3);
lcd.refresh();
ThisThread::sleep_for(5000ms);
//dark mode every 3 levels
if (level % 3 == 0) {
darkMode = true;
} else {
darkMode = false;
}
printf("Generating next level...\n");
printf("Level: %d\n", level); // Print the next level
generateMaze(map); // Generate a new maze
printMaze(map); // Print the new maze to the console
swapCurrentWall(); // Swap the current wall textures
x = 9, y = 9;
}
void swapCurrentWall() {
int i = rand() % 6 + 1;
switch (i) {
case 1: wallH = wall1; break;
case 2: wallH = wall2; break;
case 3: wallH = wall3; break;
case 4: wallH = wall4; break;
case 5: wallH = wall5; break;
case 6: wallH = wall6; break;
}
i = rand() % 6 + 1;
switch (i) {
case 1: wallV = wall1; break;
case 2: wallV = wall2; break;
case 3: wallV = wall3; break;
case 4: wallV = wall4; break;
case 5: wallV = wall5; break;
case 6: wallV = wall6; break;
}
}