Hey guys,
I'm working on a simple little game thing. I've asked for help on this forum before and received it but I'm stuck again.
In the game, a map is drawn based on constant variables set at the beginning of the code. I have a constant variable for the amount of enemies, or as I refer to them, "mobs", as well. I'm trying to make it so that the code generates random positions for the mobs, sets their position into an array, then places them down
in another function when I draw the map.
Essentially my problem is that I'm trying to make it so that when I change the constant value of the number of mobs (mobQTY), it will generate that amount in all cases. When I'm drawing the map, this is the code:
char c = '.';
int place = 0;
int mobNum = 0;
bool mobGen = true;
system("cls");
for (int j=0; j<VERTICLE; j++){
cout << " ";
for (int i=0; i<HORIZONTAL; i++){
if (endLevel == place){
c = 'O';
}
elseif (mobs[mobNum] == place){
c = 'X';
mobNum++; }
elseif (player_coord == place){
c = 'T';
}
else{
c = '.';
}
board[j][i] = c;
cout << " " << board[j][i];
place++;
}
cout << endl;
}
Everything works except for the mob placement. I'm trying to make it so that it will put all of the mobs down on the map until it reaches it's mobQTY limit.
Am I using arrays incorrectly here? Any fix to this?
It is just a pain and disincentive to help if the questions are unclear and fragmented as they were in your other post. It also helps if you post all your code not just snippets. If stated clearly in English exactly what the game does as you might explain in English exactly how Othello, chess, checkers, or an ascii dungeons game works then coding it becomes easy or easier. Programming is really just translating from a human language description of a set of rules to manipulate data into their computer language equivalent.