-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bomb.cpp
43 lines (37 loc) · 898 Bytes
/
Bomb.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
#include "Bomb.h"
#include "Character.h"
#include <iostream>
#include <allegro5/allegro_primitives.h>
Bomb::Bomb(int xPos, int yPos, WeaponProperties weaponProperties, Character * watcher):
Weapon(xPos, yPos, weaponProperties, watcher),timer(200){}
void Bomb::Update()
{
if (destroyThis)
{
delete this;
return;
}
timer--;
if (timer == 0)
{
Detonate();
}
}
void Bomb::Detonate()
{
destroyThis = true;
}
void Bomb::Action( Character * character)
{
if (character->Visit(*this))
{
destroyThis = true;
}
}
void Bomb::Draw(ALLEGRO_BITMAP *buffer, int midX, int midY)
{
al_set_target_bitmap(buffer);
al_draw_filled_circle (midX+GetX(), midY+GetY(), 2, al_map_rgb (125,0,0));
if (destroyThis)
al_draw_filled_circle (midX+GetX(), midY+GetY(), GetProperties().GetRadius(), al_map_rgb (255,0,0));
}