Friday, February 16, 2018

How to move monsters in a C++ game?


I'm creating a dungeon crawler in C++ and I'm almost done but I need to make the monster move and I'm at the end of my wits.


This is my map:


Char Map[10][10];

and this is how I initialize the positions of the monsters:


void fieldinfo::RandomizeMonsterPositions()
{

amountEnemies=10;
srand(time(0));

for(i=0; i map[rand()%9][rand()%9] = enemy;
}
}

fieldinfo is the name of my class.


Each time the player moves, the map is redrawn with the updated players position and I need the monster to move every time the player does (randomly or not I don't care).





No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...