I am experiencing problems with this function:
void move (Room&);
For some reason the compiler is saying that this is a variable or field, here is the implementation:
void Monster::move (Room& room)
{
vector<int> iCoordinates;
vector<int> jCoordinates;
for (int i = x - 1 ; i <= x + 1 && i < room.getRows() ; i++)
{
for (int j = y - 1 ; j <= y + 1 && j < room.getCols() ; j++)
{
if (i < 0)
break;
else if (j < 0)
continue;
else if (i == x && j == y)
continue;
else if (room.map[i][j] == 'H')
{
Explorer hero = room.getHero();
hero.setHP(hero.getHP() - getDamage());
return;
}
else if (room.map[i][j] == '-')
{
iCoordinates.push_back(i);
jCoordinates.push_back(j);
}
}
}
if (iCoordinates.size > 0)
{
srand (time(NULL));
int numberChosen = rand() % iCoordinates.size();
room.map[x][y] = '-';
room.map[iCoordinates.at(numberChosen)][jCoordinates.at(numberChosen)] = 'M';
x = iCoordinates.at(numberChosen);
y = jCoordinates.at(numberChosen);
}
}
I have included Room into Monster.h
#include "Room.h"
I have been trying to figure this out searching everywhere, but I cannot find an example similar to mine.
Thanks for reading!
EDIT: This is what the compiler says: variable or field `move' declared void