-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmessage.cpp
58 lines (52 loc) · 1.05 KB
/
message.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
#include "message.h"
#include "player.h"
const char* text[] = {
"-- celeste mountain --",
"this memorial to those",
" perished on the climb"
};
const int text_size = 66;
char tmp_text[23];
const int tmp_text_size = 22;
Message::Message()
: Object(message)
{
spr = 86;
}
void Message::draw()
{
drawSprite(spr, x, y);
if (check(player, 4, 0))
{
if (index < text_size)
{
// in lua it's index += 0.5, so I changed it to "+1" every other frame.
if (frames % 2)
index += 1;
if (index >= last + 1)
{
last++;
}
}
Point off;
off.x = 20;
off.y = 96;
for (int i = 0; i < 3; i++)
{
if (index > i * tmp_text_size)
{
int tmp_index = min(22, index - i * tmp_text_size);
memcpy(tmp_text, text[i], tmp_index);
tmp_text[tmp_index] = '\0';
rectfill(off.x - 2, off.y - 2, off.x + 2 + (4 * tmp_index), off.y + 8, 7);
print(tmp_text, off.x, off.y, 0);
off.y += 7;
}
}
}
else
{
index = 0;
last = 0;
}
}