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