-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexit.cpp
72 lines (54 loc) · 1.13 KB
/
exit.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* exit.cpp
*
* Created on: 2013-09-04
* Author: Liam
*/
#include "exit.h"
Exit::Exit():m_nextLevel(Restart) {
m_properties = EXIT;
fillImage();
}
Exit::Exit(const vec2d &pos, const state &nextLevel):m_nextLevel(nextLevel) {
m_pos = pos;
m_properties = EXIT;
fillImage();
}
bool Exit::write(std::ofstream &file) {
if (file.is_open()) {
int id = EXITCREATOR;
file << std::dec << id << ' ';
Entity::write(file);
file << m_nextLevel << std::endl;
return true;
} else return false;
}
bool Exit::read(std::ifstream &file) {
if (file.is_open()) {
Entity::read(file);
unsigned int i;
file >> std::dec >> i;
m_nextLevel = i;
return true;
} else return false;
}
void Exit::fillImage() {
CHAR chars[12] = {
255, 205, 205, 255,
186, 178, 178, 186,
186, 178, 178, 186
};
COL colours[12] = {
0, 0, 0, 0,
0, 15, 15, 0,
0, 15, 15, 0
};
for (int i = 0; i < 12; ++i) {
colours[i] |= BACKGROUND_BLUE;
}
Image image(4, 3, chars, colours);
m_image = image;
}
Entity *_ExitCreator::create(const vec2d &pos, const vec2d &dummy, const int &state) const {
return new Exit(pos, state);
}