-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBomb.cpp
More file actions
75 lines (70 loc) · 1.22 KB
/
Bomb.cpp
File metadata and controls
75 lines (70 loc) · 1.22 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
66
67
68
69
70
71
72
73
74
75
#include "Bomb.h"
Bomb::Bomb(Player *p)
{
father = p;
x = p->get_X();
y = p->get_Y();
map_x = x / SPRITE_SIZE;
map_y = y / SPRITE_SIZE;
range = p->get_Range();
life = true;
explode = false;
turns_2explode = turns_2explode/p->get_Speed();
player_id = p->get_Id();
if ( !draw_screen )
{
turns_2explode = turns_2explode/3;
turns_2disapear = turns_2disapear/3;
}
}
/* TODO:
- Moving bombs, update shall update its' position
*/
bool Bomb::update()
{
if( !explode )
{
turns_2explode--;
if ( turns_2explode < 0 )
{
explode = true;
father->bomb_Exploded();
}
}
else
{
turns_2disapear--;
if ( turns_2disapear <= 0 )
{
return false;
}
}
return true;
}
const char* Bomb::get_Skin()
{
if ( explode )
return explosion_skin;
else
return skin;
}
void Bomb::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;
}