-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy path09_bouncetext.cpp
31 lines (26 loc) · 958 Bytes
/
09_bouncetext.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
#include <library.h>
int x = BIOS::LCD::Width/2, y = BIOS::LCD::Height/2;
int dx = 1, dy = 1;
char text[20] = "Hello";
volatile struct {uint8_t r, g, b; } color = {255, 0, 0};
int main(void)
{
CRect inner(8, 14+8, BIOS::LCD::Width-8, BIOS::LCD::Height-14-8);
BIOS::LCD::Bar(inner, RGB565(404040));
BIOS::LCD::Rectangle(inner, RGB565(b0b0b0));
while (!BIOS::KEY::GetKey())
{
x += dx;
y += dy;
CRect draw(x, y, x+strlen(text)*8, y+14);
BIOS::LCD::Print(x, y, RGB565RGB(color.r, color.g, color.b),
RGB565(404040), text);
if (draw.right+dx >= inner.right) dx = -abs(dx);
if (draw.left+dx <= inner.left) dx = +abs(dx);
if (draw.bottom+dy >= inner.bottom) dy = -abs(dy);
if (draw.top+dy <= inner.top) dy = +abs(dy);
BIOS::SYS::DelayMs(5);
BIOS::LCD::Bar(draw, RGB565(404040));
}
return 0;
}