-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReticle.cpp
35 lines (31 loc) · 938 Bytes
/
Reticle.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
#include "Reticle.h"
#include "EventMouse.h"
#include "DisplayManager.h"
#include "WorldManager.h"
#include "LevelManager.h"
Reticle::Reticle() {
levelM.insertProtected(this);
setType("Reticle");
setSolidness(df::SPECTRAL);
setAltitude(3);
df::Vector pos(WM.getBoundary().getHorizontal() / 2,
WM.getBoundary().getVertical() / 2);
setPosition(pos);
}
//Handles events
int Reticle::eventHandler(const df::Event* p_e) {
if (p_e->getType() == df::MSE_EVENT) {
const df::EventMouse* p_mouse_event =
dynamic_cast <const df::EventMouse*> (p_e);
if (p_mouse_event->getMouseAction() == df::MOVED) {
//Moves with cursor
setPosition(p_mouse_event->getMousePosition());
return 1;
}
}
return 0;//Ignore event
}
//Draws the reticle on the window
int Reticle::draw() {
return DM.drawCh(getPosition(), RETICLE_CHAR, df::WHITE);
}