Basic ASCII game trouble

Hello community. I am trying to program a basic text based game based on what I can remember from high school classes, and I'm stuck on a certain part. I've searched the internet and my old textbook, but can't figure out what I'm doing wrong. Excuse me if I describe things incorrectly, it's been about 5 years and I'm a bit rusty.

The problem is in the random enemy encounter, in function battle(). My goal is to first determine the number of monsters that appear, which is value mcount and should be between 1-8, then assign the variables cmonsters[0] to cmonsters[7] a value based on the values of mapinfo[clvl][26] to mapinfo[clvl][33], where clvl is the map the character is currently on. It shouldn't assign any more variables to cmonsters than mcount. If you compile this and are on the first map in the game (clvl 0), when you get in a random encounter by walking around with the w, a, s, and d keys, it should assign the numbers 11, 22, 33, 44, 55, 66, 77, or 88 for the number of cmonsters equal to mcount, but seems to assign them to 0 about 4 out of 5 times.

I can't for the life of me figure out how to fix this, and would appreciate any help greatly. I put a line of *'s in the area that seems to be problematic [ line 193 of the second post, in function battle() ]. I'm going to have to put it in two posts, its too long. Thank you for looking.

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
// 041510.0046 DM
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "time.h"

#define X 215       // Wall
#define D 35        // Door (Locked)
#define K 11        // Key
#define W 37        // Water
#define Q 216       // Teleporter
#define B 240       // Bomb
#define R 120       // Bombable wall
#define T 207       // Tree
#define EDGE1 13    // Max south border
#define EDGE2 30    // Max east border

void debug();       // Debug Mode
void display();     // Prints the map
void usedir();      // Enacts the input keystroke
void printstring(); // Prints the info string, if any
void lookat();      // Look at an object
void enactmap();    // Does command of current map-tile (Pick up key, teleport, ect..)
void battle();      // Random battle
void bdisplay();    // Battle display

 int x=25,y=2,clvl=0;  // Character X/Y, Current Map
 int keys,bombs;       // Amount of key/bombs currently possessed    '
 int rn;

 int HP=10,MP=10,STR=10,DEX=10,INT=10,STA=10,LVL=0;
 int cHP=10,cMP=10,cSTR=10,cDEX=10,cINT=10,cSTA=10,cXP=0;
 int lvlup[5]={25,35,45,55,65};

 int mcount=1;                                        // Number of monsters in current battle
 int cmonsters[8]={999,999,999,999,999,999,999,999,}; // Types of monsters in current battle

 char dir;               // Input command
 int count,count2;       // Used in for() loops
 float fcount,fcount2;   // Used in float for() loops
 int temp;               // Temp value
 float ftemp;            // Temp float point value
 int skipclear=0;        // Skips the clrscr() command in display()
 int currstring=0;       // Current string at bottom of display()

 int map[3][EDGE1][EDGE2] = {
  T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,W,W,W,W,W,W,W,W,W,W,T,T,T,T,T,
  T,T,0,0,0,0,T,T,T,T,T,T,T,T,T,T,T,W,W,W,W,W,W,W,0,0,0,T,T,T,
  0,0,0,T,0,0,0,0,0,T,T,T,T,X,X,X,X,X,X,W,W,W,0,0,0,0,0,0,T,T,
  W,0,0,0,0,T,0,0,0,0,0,0,T,X,0,0,0,0,X,0,0,0,0,0,0,0,0,0,T,T,
  W,W,W,0,0,0,0,0,0,0,0,0,0,X,0,B,0,0,X,0,0,0,0,0,T,0,0,0,0,T,
  W,W,W,W,0,0,0,0,0,0,0,0,0,X,0,0,0,0,X,0,0,0,0,T,T,T,0,0,0,T,
  W,W,W,W,W,W,0,0,0,T,0,0,0,X,X,X,D,X,X,0,0,0,T,T,T,0,0,0,0,T,
  W,W,W,W,W,W,W,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,T,T,
  W,W,W,W,W,W,W,0,0,0,0,0,0,0,0,0,0,0,0,0,T,0,0,0,T,0,0,T,T,T,
  W,W,W,W,W,W,0,0,0,T,T,T,T,0,0,0,0,T,0,0,0,0,0,0,0,0,0,T,T,T,
  W,W,W,W,W,0,0,T,T,T,T,T,T,T,T,0,0,0,0,0,0,0,0,0,0,0,T,T,T,T,
  W,W,W,W,T,T,T,T,T,T,T,T,T,T,T,T,T,T,0,0,T,T,T,T,0,T,T,T,T,T,
  W,W,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,

  T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
  T,T,T,T,T,T,0,0,0,T,0,0,0,T,T,T,T,T,T,T,T,T,T,T,T,0,0,0,T,T,
  T,T,T,T,0,0,0,T,0,0,0,0,0,0,0,0,T,T,T,T,T,T,T,0,0,0,0,0,0,0,
  T,T,0,0,0,0,0,0,0,0,0,0,T,0,0,0,0,0,T,T,T,T,0,0,0,0,0,0,W,W,
  T,T,0,T,0,0,W,W,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,W,W,W,W,W,
  T,K,0,0,W,W,W,W,W,0,T,0,0,0,0,T,0,0,0,0,0,0,0,W,W,W,W,W,W,W,
  T,T,0,W,W,W,W,W,W,W,0,0,0,0,0,0,0,0,0,T,0,0,W,W,W,W,W,W,W,W,
  T,T,0,0,0,0,W,W,W,W,0,0,0,T,0,0,0,0,0,0,0,0,W,W,W,W,W,W,W,W,
  T,T,0,T,0,0,0,W,W,0,0,T,0,0,0,0,0,0,T,0,0,0,0,W,W,W,W,W,W,W,
  T,T,T,0,0,T,0,0,0,0,0,0,0,0,T,T,0,0,0,0,0,T,0,W,W,W,W,W,W,W,
  T,T,T,T,0,0,0,0,0,T,0,0,0,T,T,T,T,0,0,0,0,0,W,W,W,W,W,W,W,W,
  T,T,T,T,T,T,0,0,0,0,0,T,T,T,T,T,T,T,0,0,W,W,W,W,W,W,W,W,W,W,
  T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,0,W,W,W,W,W,W,W,W,W,W,

  T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,0,W,W,W,W,W,W,W,W,W,W,
  0,T,T,T,T,T,0,0,0,T,T,T,T,0,0,T,T,0,0,0,0,0,W,W,W,W,W,W,W,W,
  0,0,0,T,T,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,W,W,W,W,W,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,W,W,W,W,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,W,W,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 };
 int mapinfo[4][34] = {
 26, 4, 5, 3, 1,    0, 2, 3, 2, 0,    // x/Telepad 1, y/Telepad 1, x/Destination, y/Destination, clvl/Destination,
  0, 0, 0, 0, 0,    0, 0, 0, 0, 0,
 99,99, 1,99, 1000, 500,               // North Edge clvl, South Edge clvl, West edge clvl, East edge clvl, Random Battle %, Extra Enemy %,
  11, 22, 33, 44, 55, 66, 77, 88,     // Random Enemies 1-8

  0, 0, 0, 0, 0,    0, 0, 0, 0, 0,    //  0, 1, 2, 3, 4,  5, 6, 7, 8, 9,
  0, 0, 0, 0, 0,    0, 0, 0, 0, 0,    // 10,11,12,13,14, 15,16,17,18,19,
 99, 2,99, 0, 1000, 500,              // 20,21,22,23,   24, 25,
  11, 22, 33, 44, 55, 66, 77, 88,     //  26, 27, 28, 29, 30, 31, 32, 33

  0, 0, 0, 0, 0,    0, 0, 0, 0, 0,
  0, 0, 0, 0, 0,    0, 0, 0, 0, 0,
  1,99,99,99, 1000, 500,
 999,999,999,999,999,999,999,999,

  0, 0, 0, 0, 0,    0, 0, 0, 0, 0,
  0, 0, 0, 0, 0,    0, 0, 0, 0, 0,
 99,99,99,99, 9999, 999,
 999,999,999,999,999,999,999,999,
 };

main()
{
 // Seeding random number
 srand(time(NULL));
 for ( ; ; )
 {
  // Show display
  display();
  // Take keystroke
  dir = getche();
  // Use keystroke
  usedir();
  // Enact map tile
  enactmap();
  // Battle
  if ( rand()%10000+1 <= mapinfo[clvl][24] )
	battle();
 }
}

void display()
{
 // Clear screen
 if (skipclear==1) skipclear=0;
 else clrscr();

 // Top border
 printf ("%c",1);
 for (count=0;count!=32;count++)
  printf ("%c",6);
 printf ("%c\n",2);
 for (count=0;count!=EDGE1;count++)
 {
  printf ("%c ",25);
  for (count2=0;count2!=EDGE2;count2++)
  {
	if (map[clvl][count][count2]=='0') printf (" ");               // Empty Ground
	else if (count==y&&count2==x) printf ("!");                    // Character
	else printf ("%c",map[clvl][count][count2]);                   // Default
  }
  printf (" %c\n",23);
 }
 // Top border
 printf ("%c",3);
 for (count=0;count!=32;count++)
  printf ("%c",6);
 printf ("%c\n",4);
 if (currstring!=0) printstring();                                // String
 else printf("\n");
 if (keys<=5)                                                     // Keys
 {
  for (count=0;count<=keys-1;count++) printf ("[%c] ",K);
  printf ("\n");
 }
 else printf ("[%c] x %d\n",K,keys);
 if (bombs<=5)                                                     // Bombs
 {
  for (count=0;count<=bombs-1;count++) printf ("[%c] ",B);
  printf ("\n");
 }
 else printf ("[%c] x %d\n",B,bombs);
 printf ("XP: [");
 for (fcount=.1;fcount<=1.1;fcount+=.1)                           // XP Bar
 {
  ftemp=fcount*lvlup[LVL];
  if (ftemp<=cXP) printf ("%c",127);
  else printf (" ");
 }
 printf ("] %d/%d\n",cXP,lvlup[LVL]);
 printf ("\n|| x: %d ||  y: %d || dir: %c || keys: %d || bombs: %d || clvl: %d\nN: %d || S: %d || W: %d || E: %d\n Fight Index: %d\ncXP: %d, lvlup[LVL]: %d",x,y,dir,keys,bombs,clvl,mapinfo[clvl][20],mapinfo[clvl][21],mapinfo[clvl][22],mapinfo[clvl][23],mapinfo[clvl][24],cXP,lvlup[LVL]);  // Temporary Status Bar
}

Last edited on
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
void usedir()
{
 if (dir=='w')                      // Up
  if (map[clvl][y-1][x]==0||map[clvl][y-1][x]==K||map[clvl][y-1][x]==Q||map[clvl][y-1][x]==B) y--;
 if (dir=='s')                      // Down
  if (map[clvl][y+1][x]==0||map[clvl][y+1][x]==K||map[clvl][y+1][x]==Q||map[clvl][y+1][x]==B) y++;
 if (dir=='d')                      // Left
  if (map[clvl][y][x+1]==0||map[clvl][y][x+1]==K||map[clvl][y][x+1]==Q||map[clvl][y][x+1]==B) x++;
 if (dir=='a')                      // Right
  if (map[clvl][y][x-1]==0||map[clvl][y][x-1]==K||map[clvl][y][x-1]==Q||map[clvl][y][x-1]==B) x--;
 if (dir=='!')                      // Admin functions
 {
  currstring=18;
  display();
  dir = getche();
  if (dir=='!') debug();             // Debug Menu
  if (dir=='~') {keys=99;bombs=99;}  // All items
  if (dir=='@') {x=10;y=4;clvl=0;}   // Unstick me
 }
 if (dir=='l') lookat();            // Look at an object
 if (dir=='k'&&keys!=0)             // Unlock Door
 {
  currstring=2;
  clrscr();
  display();
  dir = getche();
  if (dir=='w'&&map[clvl][y-1][x]==D)
  {
	map[clvl][y-1][x]=0;
	keys--;
	currstring=4;
	goto skipotherdoorcheck;
  }
  if (dir=='s'&&map[clvl][y+1][x]==D)
  {
	map[clvl][y+1][x]=0;
	keys--;
	currstring=4;
	goto skipotherdoorcheck;
  }
  if (dir=='d'&&map[clvl][y][x+1]==D)
  {
	map[clvl][y][x+1]=0;
	keys--;
	currstring=4;
	goto skipotherdoorcheck;
  }
  if (dir=='a'&&map[clvl][y][x-1]==D)
  {
	map[clvl][y][x-1]=0;
	keys--;
	currstring=4;
	goto skipotherdoorcheck;
  }
  if (dir=='w'&&map[clvl][y-1][x]!=D) currstring=5;     // No door in that direction
  if (dir=='s'&&map[clvl][y+1][x]!=D) currstring=5;
  if (dir=='d'&&map[clvl][y][x+1]!=D) currstring=5;
  if (dir=='a'&&map[clvl][y][x-1]!=D) currstring=5;
  skipotherdoorcheck:
 }
 if (dir=='k'&&keys==0) currstring=3;             // No keys
}

void lookat()
{
 currstring=6;
 display();
 dir = getche();
 if (dir=='w')
 {
  if      (map[clvl][y-1][x]==0) currstring=101;
  else if (map[clvl][y-1][x]==X) currstring=102;
  else if (map[clvl][y-1][x]==K) currstring=103;
  else if (map[clvl][y-1][x]==D) currstring=104;
  else if (map[clvl][y-1][x]==W) currstring=105;
  else if (map[clvl][y-1][x]==Q) currstring=106;
  else if (map[clvl][y-1][x]==B) currstring=107;
  else if (map[clvl][y-1][x]==R) currstring=108;
  else if (map[clvl][y-1][x]==T) currstring=109;
  else currstring=11;
 }
 if (dir=='s')
 {
  if      (map[clvl][y+1][x]==0) currstring=101;
  else if (map[clvl][y+1][x]==X) currstring=102;
  else if (map[clvl][y+1][x]==K) currstring=103;
  else if (map[clvl][y+1][x]==D) currstring=104;
  else if (map[clvl][y+1][x]==W) currstring=105;
  else if (map[clvl][y+1][x]==Q) currstring=106;
  else if (map[clvl][y+1][x]==B) currstring=107;
  else if (map[clvl][y+1][x]==R) currstring=108;
  else if (map[clvl][y+1][x]==T) currstring=109;
  else currstring=11;
 }
 if (dir=='a')
 {
  if      (map[clvl][y][x-1]==0) currstring=101;
  else if (map[clvl][y][x-1]==X) currstring=102;
  else if (map[clvl][y][x-1]==K) currstring=103;
  else if (map[clvl][y][x-1]==D) currstring=104;
  else if (map[clvl][y][x-1]==W) currstring=105;
  else if (map[clvl][y][x-1]==Q) currstring=106;
  else if (map[clvl][y][x-1]==B) currstring=107;
  else if (map[clvl][y][x-1]==R) currstring=108;
  else if (map[clvl][y][x-1]==T) currstring=109;
  else currstring=11;
 }
 if (dir=='d')
 {
  if      (map[clvl][y][x+1]==0) currstring=101;
  else if (map[clvl][y][x+1]==X) currstring=102;
  else if (map[clvl][y][x+1]==K) currstring=103;
  else if (map[clvl][y][x+1]==D) currstring=104;
  else if (map[clvl][y][x+1]==W) currstring=105;
  else if (map[clvl][y][x+1]==Q) currstring=106;
  else if (map[clvl][y][x+1]==B) currstring=107;
  else if (map[clvl][y][x+1]==R) currstring=108;
  else if (map[clvl][y][x+1]==T) currstring=109;
  else currstring=11;
 }
}

void enactmap()
{
 if (map[clvl][y][x]!=0)
 {
  // Get Key
  if (map[clvl][y][x]==K)
  {
	map[clvl][y][x]=0;
	keys++;
	currstring=1;
  }
  // Get bomb
  else if (map[clvl][y][x]==B)
  {
	map[clvl][y][x]=0;
	bombs++;
	currstring=14;
  }
  // Warp
  else if (map[clvl][y][x]==Q)
  {
	if (mapinfo[clvl][0]==x && mapinfo[clvl][1]==y)
	{ x=mapinfo[clvl][2]; y=mapinfo[clvl][3]; clvl=mapinfo[clvl][4]; }
	else if (mapinfo[clvl][5]==x && mapinfo[clvl][6]==y)
	{ x=mapinfo[clvl][7]; y=mapinfo[clvl][8]; clvl=mapinfo[clvl][9]; }
	else if (mapinfo[clvl][10]==x && mapinfo[clvl][11]==y)
	{ x=mapinfo[clvl][12]; y=mapinfo[clvl][13]; clvl=mapinfo[clvl][14]; }
	else if (mapinfo[clvl][15]==x && mapinfo[clvl][16]==y)
	{ x=mapinfo[clvl][17]; y=mapinfo[clvl][18]; clvl=mapinfo[clvl][19]; }
  }
 }
 // Edge of map warp
 if (x==0||y==0||x==29||y==12)
 {
  if (y==0)  // North
  {
	clvl=mapinfo[clvl][20];
	y=11;
  }
  if (y==12)  // South
  {
	clvl=mapinfo[clvl][21];
	y=1;
  }
  if (x==0)   // West
  {
	clvl=mapinfo[clvl][22];
	x=28;
  }
  if (x==29)  // East
  {
	clvl=mapinfo[clvl][23];
	x=1;
  }
 }
}

void battle()
{
 // Reset old statistics
 mcount=1;
 cmonsters[0]=999;cmonsters[1]=999;cmonsters[2]=999;cmonsters[3]=999;
 cmonsters[4]=999;cmonsters[5]=999;cmonsters[6]=999;cmonsters[7]=999;
 // Determine number of monster to fight
 for ( ; ; )
 {
  if (rand()%1000+1<=mapinfo[clvl][25]&&mcount!=8)
	mcount++;
  else break;
 }
 // Determine type of monsters to fight                              *********************
 for (count=0;count!=mcount;count++)
 {
  rn=rand()%33+26;
  cmonsters[count]=mapinfo[clvl][rn];
 }
 // Start battle
 for ( ; ; )
 {
  bdisplay();
  dir = getche();
  break;
 }
 // Give out XP? Finish up?
}

void bdisplay()
{
  clrscr();
  printf ("Random Encounter:\n\n");
  printf ("mcount: %d\ncmonsters[0-7]: %d  %d  %d  %d  %d  %d  %d  %d  ",mcount,cmonsters[0],cmonsters[1],cmonsters[2],cmonsters[3],cmonsters[4],cmonsters[5],cmonsters[6],cmonsters[7]);
}

void printstring()
{
 if (currstring==1) printf ("You picked up a key.");
 else if (currstring==2) printf ("Unlock door in which direction?");
 else if (currstring==3) printf ("You have no keys to unlock doors with.");
 else if (currstring==4) printf ("You have unlocked the door.");
 else if (currstring==5) printf ("There is no door in that direction.");
 else if (currstring==6) printf ("Which direction would you like to look?");
 else if (currstring==11) printf ("You're not quite sure what you're looking at.");
 else if (currstring==14) printf ("You pick up a bomb.");
 else if (currstring==18) printf ("Enter admin function:");
 // Look function
 else if (currstring==101) printf ("You see nothing of interest.");
 else if (currstring==102) printf ("You see a solid, unbreakable wall.");
 else if (currstring==103) printf ("You see a key lying on the floor.");
 else if (currstring==104) printf ("You see a gate with a keyhole in the center.");
 else if (currstring==105) printf ("You see your reflection in a body of water.");
 else if (currstring==106) printf ("You see a teleportation pad.");
 else if (currstring==107) printf ("You see a bomb lying on the ground.");
 else if (currstring==108) printf ("You see a less-than-sturdy looking wall.");
 else if (currstring==109) printf ("You see a towering oak tree.");

 printf ("\n");
 currstring=0;
}




void debug()
{
 clrscr();
 for ( ; ; )
 {
  printf("\n  -         -\n - DEBUGGING - \n  -         -\n\n");
  dir = getche();
  if (dir=='l')
  {
	for (count=1;count<=255;count+=3)
	 printf ("    %d - %c    |    %d - %c    |    %d - %c    \n",count,count,count+1,count+1,count+2,count+2);
	goto noclear;
  }
  if (dir==',') clvl--;
  if (dir=='.') clvl++;
  printf ("---------------------------------------\n");
  if (dir=='!')
  {
	clrscr();
	break;
  }
  clrscr();
  noclear:
 }
}
Last edited on
Please use codetags. There is absolutely no way I am going to try to read that without indentation or highlighting.

Read: http://www.cplusplus.com/articles/firedraco1
Thank you, I knew there must be some way to do that, but couldn't find it on the basic FAQ, not to mention it was about 3 in the morning when I was posting. I appreciate it, and now I can say that I think the problem lies on line 193 of the second post. I'm sorry the box is stretched so far, but I am a very basic programmer and I obviously don't code in the most concise way. Also, some of the indentation seemed to get semi altered, but not in what I consider an overly frustrating way.. sorry about this, I don't know why.
Last edited on
Line 196: rn=rand()%33+26;

If I correctly understand what you're trying to accomplish there, you want to generate a random number from 26 to 33.

That line is generating a random number from 0-32, then adding 26 to that, so your variable rn can range from 26-58.

What you probably want instead is rn=rand()%8+26;, which will give you an rn ranging from 26 to 33.
That is exactly what I was trying to accomplish, and it now works perfectly. Thank you so much for your help, I appreciate it greatly.
Post the code, I wanna play the game, lol....... ;)
He has.
Oh. Well It was missing a function, so I thought there was another cpp file that had it or something.
Topic archived. No new replies allowed.