-
Notifications
You must be signed in to change notification settings - Fork 0
/
RapidFire.cpp
40 lines (37 loc) · 1.09 KB
/
RapidFire.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
/*
* RapidFire.cpp
*
* Created on: Sep 4, 2013
* Author: ian
*/
#include "RapidFire.h"
#include "LogManager.h"
#include "ResourceManager.h"
RapidFire::RapidFire(Position pos) {
LogManager &log_manager = LogManager::getInstance();
ResourceManager &resource_manager = ResourceManager::getInstance();
WorldManager &world_manager = WorldManager::getInstance();
Sprite *p_temp_sprite = resource_manager.getSprite("rapid");
if (!p_temp_sprite) {
log_manager.writeLog("Rapid::Rapid(): Warning! Sprite '%s' not found",
"rapid");
} else {
setSprite(p_temp_sprite);
setSpriteSlowdown(4);
}
// set object type
setType("rapid");
registerInterest(COLLISION_EVENT);
setPosition(pos);
}
void RapidFire::hit(EventCollision *p_c) {
if ((p_c->getObject1()->getType() == "Bullet")
|| (p_c->getObject2()->getType() == "Bullet")) {
// make sure extra rapid fires stay around
WorldManager &world_manager = WorldManager::getInstance();
if((p_c->getObject1()->getType() == "Bullet"))
world_manager.markForDelete(p_c->getObject1());
else
world_manager.markForDelete(p_c->getObject2());
}
}