-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparrot.java
More file actions
60 lines (53 loc) · 930 Bytes
/
Copy pathparrot.java
File metadata and controls
60 lines (53 loc) · 930 Bytes
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
import board.*;
import types.*;
import pimoroni.*;
@Board(Type.Picosystem)
@Picosystem(DoublePixels = true, StartupLogo = false)
class parrot
{
static @unsigned final short[] parrot_image = null;
static buffer parrot = new buffer(120, 120, parrot_image);
static int x = 0;
static int y = 0;
static void init()
{
}
static void update(@unsigned int tick)
{
if (picosystem.button(picosystem.LEFT))
{
x -= 1;
}
else if (picosystem.button(picosystem.RIGHT))
{
x += 1;
}
if (picosystem.button(picosystem.UP))
{
y -= 1;
}
else if (picosystem.button(picosystem.DOWN))
{
y += 1;
}
}
static void draw(@unsigned int tick)
{
int dx = x;
int dy = y;
int width = 120;
int height = 120;
if (x < 0)
{
width += x;
dx = 0;
}
if (y < 0)
{
height += y;
dy = 0;
}
picosystem.clear();
picosystem.blit(parrot, 120-width, 120-height, width, height, dx, dy);
}
}