-
Notifications
You must be signed in to change notification settings - Fork 0
/
wizard.cpp
58 lines (48 loc) · 1.03 KB
/
wizard.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
#include "wizard.h"
#include <iostream>
using namespace std;
/** wizard **
*
* See header file for comments
*
**/
wizard::wizard(int startX, int startY, player* _player)
{
character = 'W';
x = startX;
y = startY;
direction = 1;
this->_player = _player;
}
wizard::~wizard()
{
}
bool wizard::update(game_board& board, int timestep)
{
if( timestep % 20 != 0)
return true;
int xDirection;
int yDirection;
if (x > _player->getX())
xDirection = -1;
else if (x < _player->getX())
xDirection = 1;
else
xDirection = 0;
if (y > _player->getY())
yDirection = -1;
else if (y < _player->getY())
yDirection = 1;
else
yDirection = 0;
QChar newChar = board.get_char(x + xDirection, y + yDirection);
if( newChar == '.' || newChar == '@' )
{
board.register_game_object(new spell(x + xDirection, y + yDirection, _player->getX(), _player->getY()));
}
return true;
}
void wizard::player_collision(game_board& board)
{
board.reset_player();
}