-
Notifications
You must be signed in to change notification settings - Fork 0
/
Monster.cpp
62 lines (48 loc) · 1.16 KB
/
Monster.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "Monster.h"
#include "Being.h"
#include <iostream>
Monster::Monster(string _name, int _health, int _strength):Being::Being(_name, _health, _strength)
{
//ctor
}
Monster::~Monster()
{
//dtor
}
int Monster::getParticularLocation(int yval, int xval)
{
if (maze->maze[yval][xval] == blnk)
{
return 0;
}
else
{
return 1;
}
}
void Monster::Move(Maze* maze)
{
int right = getParticularLocation(yLocation, xLocation+1);
int left = getParticularLocation(yLocation, xLocation-1);
int down = getParticularLocation(yLocation+1, xLocation);
int up = getParticularLocation(yLocation-1, xLocation);
if (right == 0)
{
}
else if (left == 0)
{
maze->maze[yLocation][xLocation] = blnk;
maze->maze[yLocation][xLocation-1] = 'M';
}
else if (down == 0)
{
maze->maze[yLocation][xLocation] = blnk;
maze->maze[yLocation+1][xLocation] = 'M';
}
else if (up == 0)
{
maze->maze[yLocation][xLocation] = blnk;
maze->maze[yLocation-1][xLocation] = 'M';
}
return;
}