-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharlesE.cpp
830 lines (788 loc) · 22 KB
/
charlesE.cpp
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
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
// Charles Enright
// CS 335 Software Engineering
// File includes AI and elements of game mechanics for first person shooter.
// Gordon says we don't need to worry about memory leaks
// at the end of the program.
#include "solidSphere.h"
#include "charlesE.h"
#include "lizandroP.h"
#define vmi vector<Mob*>::iterator
#define vwi vector<Wall>::iterator
class Wall;
class Map;
bool mapToggle(int t = -1) {
static bool toggle = 0;
if (t == 1)
toggle = 1;
else if (t == 0)
toggle = 0;
return toggle;
}
bool dinoToggle(int t = -1) {
static bool toggle = 1;
if (t == 1)
toggle = 1;
else if(t == 0)
toggle = 0;
return toggle;
}
Mob::~Mob()
{
if (hasMap)
/// delete this->map2d;
return;
}
Mob::Mob()
{
this->hp = 0;
}
Mob::Mob(int mobID, Vec* spawnpoint)
{
this->hp = 30;
this->id = mobID;
body.redraw(1.5, 10, 10);
this->spawn(spawnpoint);
this->texture = 0;
this->moved = (int)(r(0,120));
// Must wait until we have walls to draw map.
// Walls are in the game object.
this->hasMap = false;
this->dino = dinoToggle();
}
void Mob::spawn(Vec* spawnpoint)
{
location.z = spawnpoint->z;
location.x = spawnpoint->x;
location.y = 2; // y is up and down.
//body.draw(location.x, location.y, location.z);
body.drawObj(location.x, location.y, location.z);
velocity.z = r(-4.05, 4.05);
velocity.x = r(.05, 4.05);
velocity.y = r(-4.05, 4.05);
}
void Mob::death(Game* g)
{
int i = 0;
for (vmi m = g->mobs.begin(); m != g->mobs.end(); i++, m++) {
if ((**m) == this->id) {
//causes an undefined behavior warning.
Mob* temp = *m;
g->mobs.erase(m);
kills(g);
delete temp;
return;
}
i++;
}
//throw -1;
}
void Mob::damage(int health, Game* g)
{
this->hp -= health;
if (this->hp <= 0) {
this->death(g);
g->killStreak++;
if (g->killStreak > g->maxKillStreak)
g->maxKillStreak = g->killStreak;
}
}
void Mob::move()
{
return;
this->move(NULL);
}
bool Mob::operator==(int b)
{
return this->id == b;
}
bool Mob::operator==(Mob* b)
{
return this->id == b->id;
}
void Mob::move(Game* g)
{
location.z += (float) velocity.z / 240.0;
location.y += velocity.y / 240.0;
location.x += velocity.x / 240.0;
if (location.y > 2) // gravity.
velocity.y -= 6.6102;
else if (location.y < 2) {
velocity.y = 0;
location.y = 1.5;
}
else
velocity.y = 0;
if (this->moved > 120) {
this->moved = 0;
if (!this->hasMap && mapToggle() == 1) {
//We don't have a map, but we need one.
this->map2d = new Map(g);
this->hasMap = true;
}
}
else {
this->moved++;
return;
}
//Put AI logic here.
//
//1) Collision detection: gather local objects
// This is done in Map::Map(); it prevents overhead from gathering
// new local objects each time.
//2) Collision detection: for each local object, is touching object?
// Done in Game::move where each mob iterates over each wall.
//3) collision detection: if touching object, bounce
// Also done in Wall:Collision.
static Vec* tmp = new Vec(0,0,0);
//*tmp = location+velocity;
//if (this->Collide(tmp) == 1) {
//}
//4) Map new route to player and start traversing route.
if (hasMap) {
tmp = this->map2d->aStar(this->location, g->position);
}
else {
tmp->x = g->position.x - this->location.x;
tmp->z = g->position.z - this->location.z;
this->location.y = 2.0;
this->velocity.y = 0.0;
this->velocity.x = 5*tmp->x;
this->velocity.z = 5*tmp->z;
}
//check if no solution; if so, jump and teleport.
if (hasMap && (tmp == NULL || ( tmp->x == 0 && tmp->z == 0))) {
// we are stuck, teleport
//Don't teleport, spawn points should take care of this.
//this->location.x += (g->position.x - this->location.x)/3;
//this->location.z += (g->position.x - this->location.z)/3;
}
else if (hasMap) { // have a vector to follow
this->velocity.x = 3 * (tmp->x);//should be about 3-5.
this->velocity.z = 3 * (tmp->z);
}
if (velocity.z > 24.075)
velocity.z = 24.075;
else if (velocity.z < -24.075)
velocity.z = -24.075;
if (velocity.z > 0.1305)
velocity.z -= .0112;
else if (velocity.z < -0.1305)
velocity.z += 0.1102;
else
velocity.z = 0;
if (velocity.y > 26.075)
velocity.y = 26.075;
else if (velocity.y < -26.075)
velocity.y = -26.075;
else if (velocity.y < 2.1)
velocity.y = 0;
if (location.y < 1.5) {
velocity.y = 2;
}
if (velocity.x > 24.075)
velocity.x = 24.075;
else if (velocity.x < -24.075)
velocity.x = -24.075;
if (velocity.x > 0.061)
velocity.x -= 0.0035;
else if (velocity.x < -0.061)
velocity.x += .035;
else
velocity.x = 0;
if (velocity.x == 0 && velocity.y == 0 && velocity.z == 0) {
velocity.x = r(-13.05, 13.05);
velocity.z = r(-13.05, 13.05);
}
}
void Mob::render()
{
//cout << "Now rendering mob " << this->id;
//this->move(g);
glBindTexture(GL_TEXTURE_2D, texture);
if (this->dino == 1)
body.drawObj(location.x, location.y, location.z);
else
body.draw(location.x, location.y, location.z);
glBindTexture(GL_TEXTURE_2D, 0);
}
/*
void Enemy::render()
{
this->move();
glBindTexture(GL_TEXTURE_2D, texture);
body.drawObj(location.x, location.y, location.z);
glBindTexture(GL_TEXTURE_2D, 0);
}
*/
int Mob::Collide(Vec* p)
{
if (body.isTouching(p->x, p->y, p->z)) {
Vec distance;
distance.x = location.x - p->x;
distance.y = location.y - p->y;
distance.z = location.z - p->z;
location.z -= distance.z;
location.y -= distance.y;
location.x -= distance.x;
velocity.z *= -1*distance.z;
velocity.y *= -1*distance.y;
velocity.x *= -1*distance.x;
return 1;
//cout << "Object touching" << " x " << this->velocity.x << " y "
//<< this->velocity.y
// << " z " << this->velocity.z<<endl;
}
return 0;
}
float r(float min, float max)
{
static float r_m = static_cast<float> (RAND_MAX);
return (
static_cast<float> (rand()) / (r_m / (max-min)) + min
);
}
/*
void Enemy::move()
{
//Never got implemented!
}
*/
cWall::cWall(int mobID, Vec* spawnpoint):Mob(mobID, spawnpoint)
{
//We're not using cWalls because...we're just not using them.
}
cWall::cWall(Vec a, Vec b, float w, float h):Mob()
{
Set(a, b, w, h);
}
void cWall::Set(Vec a, Vec b, float w = 2, float h = 2)
{
float offsets[][4] = {
{1, -1, 1, 1},
{1, 1, 1, -1},
{-1, 1, -1, -1},
{-1, -1, -1, 1}
};
this->endpoints[0] = a;
this->endpoints[1] = b;
this->height = h;
this->width = w;
this->color.x = 0.1;
this->color.y = 0.1;
this->color.z = 0.2;
float length = (a - b).Magnitude();
w = w / 2.0;
Vec dif = (b - a);
float xScale = dif.x / length;
float zScale = dif.z / length;
// Z is the second flat axis; y is the vertical axis.
for (int i = 0; i < 4; i++)
{
this->corners[i] = Vec(
endpoints[i / 2].x - w * (
offsets[i][0] * xScale + offsets[i][1] * zScale
),
0,
endpoints[i / 2].z - w * (
offsets[i][2] * zScale + offsets[i][3] * xScale
)
);
corners[i+4] = corners[i] + Vec(0, height, 0);
}
}
void cWall::Draw()
{
int sides[][4] = {
{0, 1, 2, 3},
{5, 4, 7, 6},
{5, 1, 0, 4},
{4, 0, 3, 7},
{7, 3, 2, 6},
{1, 5, 6, 2}
};
glColor3f(color.x, color.y, color.z);
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glNormal3fv(
&Normal(
this->corners[ sides[i][2] ],
this->corners[ sides[i][1] ],
this->corners[ sides[i][1] ])[0]
);
for (int j = 0; j < 4; j++) {
glVertex3fv(&corners[sides[i][j]][0]);
}
glEnd();
}
}
int cWall::Collide(Vec * pos, float diameter = 0)
{
Vec position = *pos;
position.y = 0.0; // this is our vertical element
Vec AP = position - this->endpoints[0];
Vec AB = this->endpoints[1] - this->endpoints[0];
float t = Dot(AB, AP) / Dot(AB, AB);
if (t < 0 || t > 1)
return 0;
Vec closestPoint = this->endpoints[0] + AB * t;
if ( ( position - closestPoint).Magnitude() < 1.0 + this->width / 2.0) {
float side = -Cross(AP, AB).y;
if (side < 0.0)
side = -1.0;
else
side = 1;
Vec perp(AB.z, 0, -AB.x);
perp.Normalize();
position = closestPoint + perp * (1 + width / 2.0) * side;
pos->x = position.x;
pos->z = position.z;
return 1;
}
return 0;
}
void Mob::setLocY(float y)
{
this->location.y = y;
}
void Mob::setVelY(float y)
{
this->velocity.y = y;
}
double celsiusToFahrenheit(double celsius)
{
static double f;
//#define _L8T_
#ifdef _L8T_
static double test[] = {
180, 356,
100, 212,
40, 104,
37, 98,
30, 86,
21, 70,
10, 50,
0, 32,
-18, 0,
-40, -40
};
printf("%lf\n", test[2*4]);
printf("%lf\n", test[2*2+1]);
printf("%lf\n", test[1*2+1]);
#endif
/*std::cout << "Enter Celcius temp: " << endl;
std::cin >> f;*/
f = (9.0/5.0) * celsius + 32;
printf("Fahrenheit: %lf\n", f);
return f;
}
double fahrToCels(double fahr)
{
static double c;
c = (5.0/9.0) * (fahr - 32);
printf("Centigrade: %lf\n", c);
return c;
}
void startAstar(Game* g)
{
static int toggle = mapToggle();
//static float wallHeight = 0.5;
if (toggle == 0) {
mapToggle(1);
//respawn_mobs(g, 10);
//Set all mobs to color red and float straight up.
for (
vmi m = g->mobs.begin();
m != g->mobs.end();
m++
) {
if (!(*m)->hasMap) {
(*m)->map2d = new Map(g);
(*m)->hasMap = true;
}
}
g->mobs[0]->hasMap = true;
for (int i = 0; i < 10; i++) {
g->mobs[0]->map2d->aStar(
*(g->mobs[0]->getLoc()), g->position
);
g->mobs[0]->map2d->displayMap();
cout << endl;
}
}
else {
mapToggle(1);
for (vmi m = g->mobs.begin(); m != g->mobs.end(); m++) {
(*m)->setVelY(-4.055);
(*m)->setLocY((*m)->getLoc()->y - 0.05);
(*m)->hasMap = false;
}
}
//exit(0); // used for testing.
}
void chadKey(Game* g, View* v)
{
static int toggle = dinoToggle();
//static float wallHeight = 0.5;
if (toggle == 1) {
toggle = dinoToggle(0);
respawn_mobs(g, 10);
//Set all mobs to color red and float straight up.
for (
vmi m = g->mobs.begin();
m != g->mobs.end();
m++
) {
(*m)->setVelY(6.055);
(*m)->dino = 0;
if (!(*m)->hasMap) {
//(*m)->map2d = new Map(g);
//(*m)->hasMap = true;
}
//cout <<"now in chadkey";
}
for (
vwi w = g->walls.begin();
w != g->walls.end();
w++
) {
w->SetHeight(0.5);
}
g->temperature = celsiusToFahrenheit(g->temperature);
}
else {
toggle = dinoToggle(1);
for (vmi m = g->mobs.begin(); m != g->mobs.end(); m++) {
(*m)->setVelY(-4.055);
(*m)->dino = 1;
(*m)->setLocY((*m)->getLoc()->y - 0.05);
//(*m)->hasMap = false;
}
for (
vwi w = g->walls.begin();
w != g->walls.end();
w++
) {
w->SetHeight(3);
}
g->temperature = fahrToCels(g->temperature);
}
}
void respawn_mobs(Game* g, int num = 10)
{
int s = g->mobs.size();
for (int i = 0; i < num; i++)
g->mobs.push_back(new Mob(s+i, new Vec(r(-20, 20), 2, r(-20, 20))));
}
Game::~Game()
{
for(
Mob* i = this->mobs.back();
!this->mobs.empty();
i = this->mobs.back()
) {
// cout << "Killing mob " << endl;
i->death(this);
mobs.pop_back();
}
/*int m = this->mobs.size();
for (int i = 0; i < m; i++) {
this->mobs[i]->death(this);
}
for(int i = 0; !this->walls.empty();this->walls.pop_back()){
i++;
// cout << "Razing wall " << i << endl;
if(i > 999) break;
this->walls.pop_back();
}
while(!this->bullets.empty()){
cout << "Killing Bullet: " << endl;
delete &this->bullets.back();
this->bullets.pop_back();
}
while(!this->bulletHoles.empty()){
cout << "Cleaning up bullet holes.";
this->bulletHoles.pop_back();
}*/
// tmpPos seems to be automatic allocation/garbage collection.
//delete[] tmpPos;
}
View::~View()
{
//delete this->game; // pointer to game object.
// delete this->dpy; Says it won't delete. How do we free this memory?
}
#include <iostream>
#include <stdio.h>
Node::Node()
{
this->visited = false;
this->cost = 9e5;
this->peeked = false;
parent[0] = 0;
parent[1] = 0;
c = '\0';
obstacle = false;
}
void Map::cleanNodes()
{
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++) {
squares[i][j]->visited = false;
squares[i][j]->cost = 9e5;
squares[i][j]->peeked = false;
squares[i][j]->parent[0] = 0;
squares[i][j]->parent[1] = 1;
squares[i][j]->c = '\0';
squares[i][j]->x = i;
squares[i][j]->z = j;
//Don't reset obstacles; map doesn't change.
}
this->current = *(new Node());
this->current.x = 0;
this->current.z = 0;
}
Map::Map(Game* g)
{
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
squares[i][j] = new Node();
this->cleanNodes();
static vector<Vec> vv;
for (vwi w = g->walls.begin(); w != g->walls.end(); w++) {
vv = w->GetPoints(2);
for (
vector<Vec>::iterator vvi = vv.begin();
vvi != vv.end();
vvi++
) {
squares[(int) (vvi->x/2) + 50][(int) (vvi->z/2) + 50]->cost = 99;
squares[(int)
(vvi->x/2) + 50][(int) (vvi->z/2) + 50]->obstacle = true;
//cout << "Obstacle: "
// << (int) vvi->x << " " << (int) vvi->z << endl;
}
}
}
bool Map::inBounds(Vec v)
{
return(v.x >= 0 && v.x <= 100 && v.z >= 0 && v.z <= 100);
}
/*
* # # #
* # @ #
* # # #
* */
void Map::getLowestCost(Vec start, Vec end)
{
double lowCost = 9e5;
// Vec temp;
// temp.x = start.x;
// temp.z = start.z;
for (int i = 15; i < 80; i++) {
if (i < 0 )
i = 0;
if (i >= 100)
i = 100;
for (int j = 15; j < 85; j++) {
if (j < 0)
j = 0;
if (j > 100)
j = 100;
if (i == current.x && j == current.z)
continue;
/* cout << "I: " << i
<< " J: " << j << " ob: " << this->squares[i][j]->obstacle
<< " v: " << this->squares[i][j]->visited
<< " cost: " << this->squares[i][j]->cost << endl;
*/ if (
!this->squares[i][j]->obstacle &&
!this->squares[i][j]->visited &&
this->squares[i][j]->cost < lowCost
) {
lowCost = squares[i][j]->cost;
this->current.x = i;
this->current.z = j;
}
}
}
if (lowCost == 9e5) {
// we are stuck. abort pathfinding.
current.x = 0;
current.z = 0;
}
}
Vec* Map::aStar(Vec start, Vec end)
{
// Dijkstra's derived from my CS 312 Lab 6. -- Charles Enright
// May contain code derived from Gordon.
static double root2 = sqrt(2);
static Vec* nextPath = new Vec();
this->cleanNodes();
cout << "Input start: " << start.x << ", " << start.z << "; "<<end.x
<< ", " << end.z << endl;
nextPath->x = (int)(end.x - start.x);
nextPath->z = (int)(end.z - start.z);
squares[(int)(start.x/2 + 50)][(int)(start.z/2 + 50)]->cost = 0.0;
squares[(int)(start.x/2 + 50)][(int)(start.z/2+50)]->c = '8';
start.x = (int) start.x/2+50;
start.z = (int) start.z/2+50;
end.x = (int) end.x/2+50;
end.z = (int) end.z/2+50;
squares[ (int) (end.x) ][ (int) end.z ]->c = '+';
cout << "Raw input converted to " << start.x << ", " << start.z
<< "; " << end.x << ", " << end.z << endl;
static int offset[8][2] = {
{-1, 0}, {1, 0},
{0, -1}, {0, 1},
{-1, -1}, {-1, 1},
{1, -1}, {1, 1}
};
int sentinal = 400;
int iter = 0;
//start new search
//if(current.x == 0 && current.z == 0) {
//} //else resume last search
//else {
// temp.x = current.x;
// temp.z = current.z;
// }
do {
if (iter > sentinal) {
cout << "Hit sentinel.";
return nextPath;
}
else {
cout << "-";
iter++;
}
int x, y;
x = current.x;
y = current.z;
getLowestCost(Vec(x, 0, y), end);
if (current.x == 0 && current.z == 0) {
//We are stuck. Abort pathfinding.
cout << "Stuck.";
return NULL;
}
cout << x << " " << y;
for (int i = 0; i < 8; i++) {
x = this->current.x + offset[i][0];
y = this->current.z + offset[i][1];
if (inBounds(Vec(x, 0, y)) &&
!squares[x][y]->visited
) {
//cout << "1";
double cost;
squares[x][y]->peeked = true;
//if diagonal, cost is root 2; else cost = 1;
if (offset[i][0] == offset[i][1]
|| offset[i][0] == -1 * offset[i][1]
) {
cost = squares[current.x][current.z]->cost + root2;
}
else {
cost = squares[current.x][current.z]->cost + 1.0;
}
double d0, d1, dist;
d0 = (double) x - end.x;
d1 = (double) y - end.z;
dist = d0*d0+d1*d1;
cost += dist;
//cout << "$" << cost << " ";
if (squares[x][y]->cost > cost) {
//cout << "+";
//exit(1);
squares[x][y]->cost = cost;
squares[x][y]->parent[0] = current.x;
squares[x][y]->parent[1] = current.z;
//squares[x][y]->c = '*';
cout << "Visit node " << x << "; " << y << endl;
}
}
else {
cout << "_";
}
}
squares[current.x][current.z]->visited = true;
usleep(1);
} while (this->current.x != end.x && this->current.z != end.z);
cout << "Found solution.";
//find next node.
static int toggle = 1;
while (this->current.parent[0] != 0 && this->current.parent[1] != 0) {
squares[(int)current.x][(int)current.z]->c = '+';
if (
(int)current.x == (int) end.x &&
(int)current.z == (int) end.z
) {
squares[(int)current.x][(int)current.z]->c = '@';
}
else if (current.parent[0] == start.x && current.parent[1] == start.z) {
squares[(int)current.x][(int)current.z]->c = '9';
nextPath = new Vec(
-2*(start.x - current.x), 0, -2*(start.z - current.z)
);
cout << "Output is " << nextPath->x << ", " << nextPath->z << endl;
return nextPath;
}
else {
squares[current.x][current.z]->c = '*';
}
current = *squares[current.parent[0]][current.parent[1]];
}
cout << "Node " << current.x << ", " << current.z << endl;
if (toggle == 1) {
this->displayMap();
}
else {
toggle = 0;
}
return new Vec(0, 0, 0);
}
void Map::displayMap()
{
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
if (this->squares[i][j]->obstacle) {
if (this->squares[i][j]->c != '\0')
cout << "\033[1;31m" << this->squares[i][j]->c << "\033[0m";
else if (this->squares[i][j]->peeked)
cout << "\033[1;34m#\033[0m";
else
cout << "\033[1;33m#\033[0m";
}
else if (this->squares[i][j]->visited) {
if (this->squares[i][j]->c != '\0')
cout << "\033[1;31m" << this->squares[i][j]->c << "\033[0m";
else
cout << "o";
}
else if (this->squares[i][j]->peeked)
cout << "\033[1;34mo" << "\033[0m";
else if (this->squares[i][j]->c != '\0')
cout << this->squares[i][j]->c;
else
cout << ".";
}
cout << endl;
}
}
void Map::renderMap(Game* g)
{
/* static int si = 0;
glBegin(GL_LINES);
Rect r;
r.bot = h - 20
r.center = 0;
r.left = 60;*/
}
Map::~Map()
{
//automatic allocate/deallocate
//delete[] squares;
}
Wall::~Wall()
{
// delete[8] c;
// delete[2] v;
}