-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.cpp
More file actions
65 lines (61 loc) · 1.04 KB
/
Player.cpp
File metadata and controls
65 lines (61 loc) · 1.04 KB
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
63
64
65
#include "Player.h"
Player::Player(const char* s, int pos_x, int pos_y, int i, int ti)
{
skin = s;
orig_x = pos_x;
orig_y = pos_y;
x = pos_x * SPRITE_SIZE;
y = pos_y * SPRITE_SIZE;
map_x = pos_x;
map_y = pos_y;
life = true;
connected = false;
id = i;
team_id = ti;
turns = 0;
num_bombs_planted = 0;
}
void Player::set_position(int xx, int yy)
{
map_x = xx;
map_y = yy;
x = xx * SPRITE_SIZE;
y = yy * SPRITE_SIZE;
}
void Player::reset_position()
{
map_x = orig_x;
map_y = orig_y;
x = orig_x * SPRITE_SIZE;
y = orig_y * SPRITE_SIZE;
}
void Player::move( int direction )
{
switch (direction)
{
case UP:
y -= VELOCITY;
break;
case DOWN:
y += VELOCITY;
break;
case LEFT:
x -= VELOCITY;
break;
case RIGHT:
x += VELOCITY;
break;
}
map_x = x / SPRITE_SIZE;
map_y = y / SPRITE_SIZE;
}
bool Player::can_Place()
{
if( num_bombs < max_num_boms)
{
num_bombs++;
num_bombs_planted++;
return true;
}
return false;
}