-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bullet.cpp
41 lines (34 loc) · 1008 Bytes
/
Bullet.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
// game engine includes
#include "LogManager.h"
#include "GraphicsManager.h"
#include "WorldManager.h"
#include "EventStep.h"
#include "EventOut.h"
// tester includes
#include "Bullet.h"
// default constructor
Bullet::Bullet(){
setType("Bullet");
}
// constructor to give initial velocity and position
Bullet::Bullet(float xVelocity, float yVelocity, df::Position pos){
setType("Bullet");
setXVelocity(xVelocity);
setYVelocity(yVelocity);
setSolidness(df::SOFT);
setPosition(pos);
}
// how to draw the bullet on the screen
void Bullet::draw(){
df::GraphicsManager::getInstance().drawString(getPosition(), ">-->", df::Justification::LEFT_JUSTIFIED, df::Color::YELLOW);
}
// Handle event (default is to ignore everything).
// Return 0 if ignored, else 1 if handled.
int Bullet::eventHandler(df::Event *p_e){
// if out of bounds then change velocity to bring back into bounds
if (p_e->getType() == DF_OUT_EVENT){
df::WorldManager::getInstance().markForDelete(this);
return 1;
}
return 0;
}