void Ghost::locateGhost(Floor Level) { for (int i = 0; i< 20; i++) { for (int j = 0; j < 30 ; j++) { if (Level.getGrid(i,j) == 'G') { y = i; x = j; } } } }
void Ghost::move(char c, Floor& Level) { point temp; if (c == 'w') { temp.y = y - 1; temp.x = x; if (Level.getGrid(temp.y,temp.x) != '#' && Level.getGrid(temp.y,temp.x) != 'D') y--; } else if(c == 'a') { temp.y = y; temp.x = x - 1; if (Level.getGrid(temp.y,temp.x) != '#' && Level.getGrid(temp.y,temp.x) != 'D') x--; } else if (c == 's') { temp.y = y+1; temp.x = x ; if (Level.getGrid(temp.y,temp.x) != '#' && Level.getGrid(temp.y,temp.x) != 'D') y++; } else if(c == 'd') { temp.y = y; temp.x = x + 1; if (Level.getGrid(temp.y,temp.x) != '#' && Level.getGrid(temp.y,temp.x) != 'D') x++; } }