Dungeon Crawl - A Few Issues...

I made the dungeon crawler game today, based off C++ beginner exercises. The program is modular and accept dynamic changes to the board size and trap count by changing just the preprocessor values. (or its suppose to). I'm having two main troubles with my code, otherwise it works great.

Problem 1.) Whenever I win or lose, it gives me an program error prompt saying that traps array is corrupt.

Problem 2.) After writing this code today, my brain hurts and I don't want to think about how to dynamically check all elements of traps (based on QTY_TRAPS preprocessor definition) within drawDungeon() and getMove(). As of now I only have hard coded if ( traps[0] == place, [1] == place, [2], [3], and [4]... I want all elements dynamically handled. So basically, I changed preprocessor QTY_TRAPS from 5 to 20 and it still only uses 5 traps. Lines 84 and 113

I will add the random moving enemies after I figure this out.

Heres my code:
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
// 7_DungeonCrawl.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;

#define VERTICLE 10			// Board Y axis dimension
#define HORIZONTAL 12		// Board X axis dimension
#define QTY_TRAPS 5			// Amount of traps to include in game
#define QTY_ENEMIES 5		// Amount of enemies to include in game

void genStatic(int traps[], int& treasure)
// Generate random locations of traps and treasure //
{	
	// Generate traps randomly based on Horizontal and Verticle preprocessor definitions
	srand(unsigned(time(NULL)));
	for (int i=0; i <= QTY_TRAPS; i++) {
		traps[i] = rand() % HORIZONTAL * VERTICLE + i;	// Set traps to random spots
		while (traps[i] == 0) {
			traps[i]++;	// Avoid trap at player start position
		}
	}
	treasure = rand() % HORIZONTAL * VERTICLE;		// Set treasure to random spot
	while (treasure == 0) {
		treasure++;	// Avoid treasure at player start position
	}
}

/*
void genEnemies(int enemies[])
// Generate random locations of enemies //
{
	
}
*/

char getMove (int& pos_player, int traps[], int& treasure)
// Get input and save player moves //
{
	char move = 'z';
	int lost = 0;
	bool needInput = true;
	while (needInput == true) {
		cin >> move;
		switch (move)
		{
			case 'w':
				if (pos_player - HORIZONTAL < 0){
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player - HORIZONTAL;	
				needInput = false;
				break;
			case 's':
				if (pos_player + HORIZONTAL >= HORIZONTAL*VERTICLE){
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player + HORIZONTAL;
				needInput = false;
				break;
			case 'a':
				if (pos_player - 1 < 0){
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player - 1;
				needInput = false;
				break;
			case 'd':
				if (pos_player + 1 > HORIZONTAL*VERTICLE-1){
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player + 1;
				needInput = false;
				break;
			default:
				cout << "Please enter correct move character: ";
				needInput = true;
				break;
		}
	}

	// Check if player landed on traps to lose or the treasure to win
	if (pos_player == traps[0] || pos_player == traps[1] || pos_player == traps[2] || pos_player == traps[3] || pos_player == traps[4]){
		lost = 1;
		return lost;
	} else if (pos_player == treasure) {
		lost = 2;
		return lost;
	} else {
	lost = 0;
	return lost;
	}
}

void drawDungeon (char board[VERTICLE][HORIZONTAL], int traps[], int treasure, int& pos_player)
// Draw the dungeon, according to values in board[][] //
{
	char symbol = '.';
	int place = 0;
	system("cls");
	cout << "\n\n\tDungeon Crawler - by r0c c4s\n";
	cout << "Get to the treasure ($) by navigating through the traps (*)!\n\n\n";

	// Lay board
	for (int j=0; j<VERTICLE; j++){
		cout << "\t  ";
		for (int i=0; i<HORIZONTAL; i++){
			
			// Lay treasure and traps on board
			if (treasure == place){
				symbol = '$';
			}else if (traps[0] == place || traps[1] == place || traps[2] == place || traps[3] == place || traps[4] == place){
				symbol = '*';
			}else if (pos_player == place){
				symbol = 'u';
			}else{
				symbol = '.';
			}

			board[j][i] = symbol;
			cout << " " << board[j][i];
			place++;
		}
		cout << "\n";
	}
	cout << "\n" << pos_player << "\n";     // Debug helper
	cout << "\n\tControls: w-(Up), s-(Down), a-(Left), d-(Right)\n";
	cout << "\nEnter your move: ";
}

void play (int traps[], int& treasure, int enemies[])
{
	char board [VERTICLE][HORIZONTAL];
	int pos_player = 0;
	int stillPlay = 0;
	while (stillPlay == 0) {
		drawDungeon(board, traps, treasure, pos_player);
		stillPlay = getMove(pos_player, traps, treasure);
	}

	if (stillPlay == 1)
		cout << "\n\n\tYou lost... Really...\n";
	else
		cout << "\n\n\tYou WIN!\tWinner, Winner, Chicken Dinner\n";
}

int main ()
{
	
	int traps[QTY_TRAPS];			// Declare traps
	int enemies[QTY_ENEMIES];	// Declare Enemies
	int treasure = 0;						// Declare treasure

	// Run game  ///////////////////////////////////////
	genStatic(traps, treasure);
	play(traps, treasure, enemies);
	cin.get();
}


EDIT* This game is much more entertaining when you try to enter all of your moves at one time, and then hit enter and try to see if you can hit the!! treasure safely!
Last edited on
Problem on line 19:

for (int i=0; i <= QTY_TRAPS; i++) {


if QTY_TRAPS is 5, this loop will run six times, one for each of these values:
0, 1, 2, 3, 4, 5

This of course means you are stepping out of bounds of your array.

You do not want <= here, you want <.

Don't know if this problem is elsewhere in the code, but this is what would cause the "traps is corrupted" problem.


As for the 2nd problem.. rather than checking each element of traps in a gigantic if statement, put it in a loop.
Last edited on
Disch Wrote:
As for the 2nd problem.. rather than checking each element of traps in a gigantic if statement, put it in a loop.


@rcast

That was what I was saying in my advice to you in your other topic.

Edit:

http://www.cplusplus.com/forum/beginner/94837/#msg509148


I can see you have used the while & switch I suggested though - which is good.

You are doing well with your code after a short time of learning - great !! Hope all is well at your end :)
Last edited on
ok guys - I fixed the two problems I had and added the randomly moving enemies. However, you will notice sometimes when you land on an enemy, the enemy simply covers the player piece and lost doesn't evaluate to 1, so the game continues. I need help here.

I think the problem is it's checking to see if you hit enemy after the enemy already moves?

If you give it a play, you'll see what I mean. The game is pretty fun now, when it works. Also the Board size, enemies, and traps are all adjustable with one digit changes to the preprocessor definitions.

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
// 7_DungeonCrawl.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;

#define VERTICLE 10		// Board Y axis dimension
#define HORIZONTAL 12		// Board X axis dimension
#define QTY_TRAPS 6			// Amount of traps to include in game
#define QTY_ENEMIES 4		// Amount of enemies to include in game

void genStatic(int traps[], int& treasure)
// Generate random locations of traps and treasure //
{	
	// Generate traps randomly based on Horizontal and Verticle preprocessor definitions
	srand(unsigned(time(NULL)));
	for (int i=0; i < QTY_TRAPS; i++) {
		traps[i] = rand() % HORIZONTAL * VERTICLE + i;	// Set traps to random spots
		while (traps[i] == 0) {
			traps[i] += 2;	// Avoid trap at player start position
		}
	}
	treasure = rand() % HORIZONTAL * VERTICLE;		// Set treasure to random spot
	while (treasure == 0) {
		treasure++;	// Avoid treasure at player start position
	}
}

void genEnemies(int enemies[], int& turn)
// Generate random locations of enemies //
{
	for (int i=0; i < QTY_ENEMIES; i++) {
		enemies[i] = rand() % HORIZONTAL * VERTICLE;
		while (enemies[i] == 0) {
			enemies[i] += 1;
		}
	}
}

char getMove (int& pos_player, int traps[], int& treasure, int enemies[])
// Get input and save player moves //
{
	char move = 'z';
	int lost = 0;
	bool needInput = true;
	while (needInput == true) {
		cin >> move;
		switch (move)
		{
			case 'w':
				if (pos_player - HORIZONTAL < 0){						// Stop out of bounds verticle top
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player - HORIZONTAL;	
				needInput = false;
				break;
			case 's':
				if (pos_player + HORIZONTAL >= HORIZONTAL*VERTICLE){		// Stop out of bounds verticle bottom
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player + HORIZONTAL;
				needInput = false;
				break;
			case 'a':
				if (pos_player - 1 < 0){
					needInput = true;
					cout << "Character is going out of range, try again: ";		// Stop out of bounds top horizontal left
					break;
				}
				pos_player = pos_player - 1;
				needInput = false;
				break;
			case 'd':
				if (pos_player + 1 > HORIZONTAL*VERTICLE-1){
					needInput = true;
					cout << "Character is going out of range, try again: ";		// Stop out of bounds horizontal bottom right
					break;
				}
				pos_player = pos_player + 1;
				needInput = false;
				break;
			default:
				cout << "Please enter correct move character: ";
				needInput = true;
				break;
		}
	}

	// Check if player landed on traps to lose
	for (int x=0; x < QTY_TRAPS; x++) {
		if (pos_player == traps[x]) {
			lost = 1;
			return lost;
		}
	}

		// Check if player touched enemies to lose
	for (int x=0; x < QTY_ENEMIES; x++) {
		if (pos_player == enemies[x]) {
			lost = 1;
			return lost;
		}
	}

	// Check if player landed on treasure to win
	if (pos_player == treasure) {
		lost = 2;
		return lost;
	} else {
	lost = 0;
	return lost;
	}
}

void drawDungeon (char board[VERTICLE][HORIZONTAL], int traps[], int treasure, int& pos_player, int enemies[])
// Draw the dungeon, according to values in board[][] //
{
	char symbol = '.';
	int place = 0;
	int randDirection = 0;
	system("cls");
	cout << "\n\n\tDungeon Crawler - by r0c c4s\n";
	cout << "Get to the treasure ($) by navigating through the traps (*)!\n\n\n";

	// Move enemies on board every turn in random direction
	srand(unsigned(time(NULL)));
	for (int i=0; i < QTY_ENEMIES; i++) {
		while (true) {
			randDirection = rand() % 3;
			if (randDirection == 0) {
				if (enemies[i] + 1 > HORIZONTAL*VERTICLE-1){
					enemies[i] = enemies[i] - 1;
					break;
				}else{
					enemies[i] = enemies[i] + 1;
					break;
				}
			}else if (randDirection == 1){
				if (enemies[i] - 1 < 0) {
					enemies[i] = enemies[i] + 1;
				}else{
					enemies[i] = enemies[i] - 1;
					break;
				}
			}else if (randDirection == 2){
				if (enemies[i] + HORIZONTAL > 120){
					enemies[i] = enemies[i] - HORIZONTAL;
					break;
				}else{
					enemies[i] = enemies[i] + HORIZONTAL;
					break;
				}
			}else if (randDirection == 3){
				if (enemies[i] - HORIZONTAL < 0){
					enemies[i] = enemies[i] + HORIZONTAL;
					break;
				}else{
					enemies[i] = enemies[i] - HORIZONTAL;
					break;
				}
			}
		}
	}

	// // Lay board elements // //
	for (int j=0; j<VERTICLE; j++){
		cout << "\t  ";
		for (int i=0; i<HORIZONTAL; i++){

			// Lay treasure  and player on board
			if (treasure == place){
				symbol = '$';
			}else if (pos_player == place){
				symbol = 'u';
			}else{
				symbol = '.';
			}

			// Lay traps on board
			for (int x= 0; x < QTY_TRAPS; x++) {
				if (traps[x] == place)
					symbol = '*';
			}

			// Lay enemies on board
			for (int x= 0; x < QTY_ENEMIES; x++) {
				if (enemies[x] == place)
					symbol = '>';
			}

			board[j][i] = symbol;
			cout << " " << board[j][i];
			place++;
		}
		cout << "\n";
	}
	cout << "\n" << pos_player << "\n";
	cout << "\n\tControls: w-(Up), s-(Down), a-(Left), d-(Right)\n";
	cout << "\nEnter your move: ";
}

void play (int traps[], int& treasure, int enemies[])
{
	char board [VERTICLE][HORIZONTAL];
	int pos_player = 0;
	int stillPlay = 0;
	int turn = 0;
	genEnemies(enemies, turn);
	while (stillPlay == 0) {
		drawDungeon(board, traps, treasure, pos_player, enemies);
		stillPlay = getMove(pos_player, traps, treasure, enemies);
		turn++;
	}

	if (stillPlay == 1)
		cout << "\n\n\tYou lost... Really...\n";
	else
		cout << "\n\n\tYou WIN!\tWinner, Winner, Chicken Dinner\n";
}

int main ()
{
	
	int traps[QTY_TRAPS];			// Declare traps
	int enemies[QTY_ENEMIES];	// Declare Enemies
	int treasure = 0;						// Declare treasure

	// Run game  ///////////////////////////////////////
	genStatic(traps, treasure);
	play(traps, treasure, enemies);
	cin.get();
}
Last edited on
I actually can't recreate the issue you're describing. I copied and ran it on my computer then played it at least ten times and it seemed to work every time. Is there something more specific about the conditions that cause this issue?
Yes, sometimes 'u' becomes '>' (they've overlapped) and when you move player another turn, then you can see 'u'.

Also I noticed, when I move player at least 40 times, all of the enemies gravitate and stay within the bottom 2 rows. Why is this
It's weird, I can't get that error to happen. Maybe the compilers are doing something differently and so the problem isn't showing up on my end.

EDIT: I notice you're using MSVS, I'm using MinGw.
Last edited on
Great, one other question. I read somewhere that srand() only generates new values when re-compiled. My question is how do I get all of the random numbers to re-generate every time the application is opened, after the program is built as executable file (batch build)?
Last edited on
closed account (Dy7SLyTq)
well you want srand(time(NULL)) and then it generates pseudo random numbers based on the system time
Ok good thats what I have. Appreciate it!

Its done:
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
// 7_DungeonCrawl.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;

#define VERTICLE 10		// Board Y axis dimension
#define HORIZONTAL 25	// Board X axis dimension
#define QTY_TRAPS 10 	// Amount of traps to include in game
#define QTY_ENEMIES 15	// Amount of enemies to include in game

void genStatic(int traps[], int& treasure)
// Generate random locations of traps and treasure //
{	
	// Generate traps randomly based on Horizontal and Verticle preprocessor definitions
	srand(unsigned(time(NULL)));
	for (int i=0; i < QTY_TRAPS; i++) {
		traps[i] = rand() % HORIZONTAL * VERTICLE + i;	// Set traps to random spots
		while (traps[i] == 0) {
			traps[i] += 2;	// Avoid trap at player start position
		}
	}
	treasure = rand() % HORIZONTAL * VERTICLE;		// Set treasure to random spot
	while (treasure == 0) {
		treasure++;	// Avoid treasure at player start position
	}
}

void genEnemies(int enemies[])
// Generate random locations of enemies //
{
	for (int i=0; i < QTY_ENEMIES; i++) {
		enemies[i] = rand() % HORIZONTAL * VERTICLE;
		while (enemies[i] == 0) {
			enemies[i] += 2;
		}
	}
}

char getMove (int& pos_player, int traps[], int& treasure, int enemies[])
// Get input and save player moves //
{
	char move = 'z';
	int lost = 0;
	bool needInput = true;
	while (needInput == true) {
		cin >> move;
		switch (move)
		{
			case 'w':
				if (pos_player - HORIZONTAL < 0){						// Stop out of bounds verticle top
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player - HORIZONTAL;	
				needInput = false;
				break;
			case 's':
				if (pos_player + HORIZONTAL >= HORIZONTAL*VERTICLE){		// Stop out of bounds verticle bottom
					needInput = true;
					cout << "Character is going out of range, try again: ";
					break;
				}
				pos_player = pos_player + HORIZONTAL;
				needInput = false;
				break;
			case 'a':
				if (pos_player - 1 < 0){
					needInput = true;
					cout << "Character is going out of range, try again: ";		// Stop out of bounds top horizontal left
					break;
				}
				pos_player = pos_player - 1;
				needInput = false;
				break;
			case 'd':
				if (pos_player + 1 > HORIZONTAL*VERTICLE-1){
					needInput = true;
					cout << "Character is going out of range, try again: ";		// Stop out of bounds horizontal bottom right
					break;
				}
				pos_player = pos_player + 1;
				needInput = false;
				break;
			default:
				cout << "Please enter correct move character: ";
				needInput = true;
				break;
		}
	}

	// Check if player landed on traps to lose
	for (int x=0; x < QTY_TRAPS; x++) {
		if (pos_player == traps[x]) {
			lost = 1;
			return lost;
		}
	}

		// Check if player touched enemies to lose
	for (int x=0; x < QTY_ENEMIES; x++) {
		if (pos_player == enemies[x]) {
			lost = 1;
			return lost;
		}
	}

	// Check if player landed on treasure to win
	if (pos_player == treasure) {
		lost = 2;
		return lost;
	} else {
	lost = 0;
	return lost;
	}
}

int drawDungeon (char board[VERTICLE][HORIZONTAL], int traps[], int treasure, int& pos_player, int enemies[])
// Draw the dungeon, according to values in board[][] //
{
	char symbol = '.';
	int place = 0;
	int randDirection = 0;
	system("cls");
	cout << "\n\n\t\tDungeon Crawler - by r0cc0 c4st0r0\n\n";
	cout << "Get(u) to the treasure($) by navigating through the traps(*) and enemies >!\n\n\n";


	// Move enemies on board every turn in random direction
	srand(unsigned(time(NULL)));
	for (int i=0; i < QTY_ENEMIES; i++) {
		while (true) {
			randDirection = rand() % 3;
			if (randDirection == 0) {
				if (enemies[i] + 1 > HORIZONTAL*VERTICLE-1){
					enemies[i] = enemies[i] - 1;
					break;
				}else{
					enemies[i] = enemies[i] + 1;
					break;
				}
			}else if (randDirection == 1){
				if (enemies[i] - 1 < 0) {
					enemies[i] = enemies[i] + 1;
				}else{
					enemies[i] = enemies[i] - 1;
					break;
				}
			}else if (randDirection == 2){
				if (enemies[i] + HORIZONTAL > 120){
					enemies[i] = enemies[i] - HORIZONTAL;
					break;
				}else{
					enemies[i] = enemies[i] + HORIZONTAL;
					break;
				}
			}else if (randDirection == 3){
				if (enemies[i] - HORIZONTAL < 0){
					enemies[i] = enemies[i] + HORIZONTAL;
					break;
				}else{
					enemies[i] = enemies[i] - HORIZONTAL;
					break;
				}
			}
		}
	}

	// // Lay board elements // //
	for (int j=0; j<VERTICLE; j++){
		cout << "\t   ";
		for (int i=0; i<HORIZONTAL; i++){

			// Lay treasure  and player on board
			if (treasure == place){
				symbol = '$';
			}else if (pos_player == place){
				symbol = 'u';
			}else{
				symbol = '.';
			}

			// Lay traps on board
			for (int x= 0; x < QTY_TRAPS; x++) {
				if (traps[x] != treasure) {
					if (traps[x] == place)
						symbol = '*';
				}
			}

			// Lay enemies on board
			for (int x= 0; x < QTY_ENEMIES; x++) {
				if (enemies[x] == place)
					symbol = '>';
				if (enemies[x] == pos_player)
					return 1;
			}

			board[j][i] = symbol;
			cout << " " << board[j][i];
			place++;
		}
		cout << "\n";
	}
	cout << "\n" << pos_player << "\n";
	cout << "\n\tControls: w-(Up), s-(Down), a-(Left), d-(Right)\n";
	cout << "\n\t\t\tEnter your move: ";
}

void play (int traps[], int& treasure, int enemies[])
{
	char board [VERTICLE][HORIZONTAL];
	int pos_player = 0;
	int stillPlay = 0;
	int turn = 0;
	genEnemies(enemies);
	while (stillPlay == 0) {
		stillPlay = drawDungeon(board, traps, treasure, pos_player, enemies);
		if (stillPlay == 1)
			break;
		stillPlay = getMove(pos_player, traps, treasure, enemies);
		turn++;
	}

	if (stillPlay == 1)
		cout << "\n\n\t\aYou lost... Really? Try again...\n";
	else
		cout << "\n\n\t\a\a\aYou WIN!\tWinner, Winner, Chicken Dinner\n";
}

int main ()
{
	
	int traps[QTY_TRAPS];			// Declare traps
	int enemies[QTY_ENEMIES];	// Declare Enemies
	int treasure = 0;						// Declare treasure
	char quarter = 'y';					// Play again?
	char tmp = 'z';

	// Run game  ///////////////////////////////////////
	while (quarter == 'y' || quarter == 'Y') {
		genStatic(traps, treasure);
		play(traps, treasure, enemies);
		cout << "\tInsert 25 Cents? y or n: ";
		cin >> quarter;
	}
	cout << "\n\nThanks for playing! Enter q to exit\n\n\n";
	cin >> tmp;
}
Last edited on
closed account (Dy7SLyTq)
np
Topic archived. No new replies allowed.