-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloor.cpp
More file actions
48 lines (38 loc) · 1.04 KB
/
Floor.cpp
File metadata and controls
48 lines (38 loc) · 1.04 KB
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
44
45
46
47
48
// game engine includes
#include "GraphicsManager.h"
#include "LogManager.h"
// IHOP includes
#include "Floor.h"
// constructor for floor needs length of section of floor
Floor::Floor(df::Position init_pos, int init_length){
setPosition(init_pos);
length = init_length;
setType("Floor");
}
// get the length of the section of floor
int Floor::getLength() const {
return length;
}
// set the length of the section of floor
void Floor::setLength(int new_length){
length = new_length;
}
// return true if position falls on floor, false otherwise
bool Floor::onMapObject(df::Position pos) const{
int x = pos.getX();
int y = pos.getY();
if (y == this->getPosition().getY() &&
x >= this->getPosition().getX() &&
x <= this->getPosition().getX() + length) {
return true;
}
return false;
}
void Floor::draw() {
df::GraphicsManager &gm = df::GraphicsManager::getInstance();
int x = getPosition().getX();
int y = getPosition().getY();
for (int i = 0; i < length; i++) {
gm.drawCh(df::Position(x + i, y), FLOOR_CHAR, df::Color::WHITE);
}
}