Random monster spawning

Hey everyone, question is i have my random set as such
random_number1 = rand() % 9;
random_number2 = rand() % 9;

Then i am spawning my monster as
//check for spawning on player
if(game[random_number1][random_number2]!=game[posX][posY]){
game[random_number1][random_number2] = monster;
}

Question is i want to despawn the previous position of the monster but the problem is i have just one variable for monster as such
monster = 'T'
and i am setting them in my array for the game as such
game[8][7] = monster;
game[7][7] = monster;
game[7][8] = monster;
and i want to delete it's previous space everytime its randomly generated a new spot on the grid.So any advice is appreciated.
I don't get it. As I can see it you simply despawn your previous position and then spawn your new one. Something like this I guess:
1
2
3
4
5
6
7
if(game[random_number1][random_number2]!=game[posX][posY]){
game[previous_random_number1][previous_random_number2] = despawn_stuff;
previous_random_number1 = random_number1; //to keep the numbers
previous_random_number2 = random_number2;

game[random_number1][random_number2] = monster;
}


Of course the first time you shouldn't do that (there are no previous random numbers!) but you can figure out a way to take care of it. Isn't this solving your problem?
Topic archived. No new replies allowed.