-
Notifications
You must be signed in to change notification settings - Fork 0
/
flappy.blr
68 lines (57 loc) · 1.33 KB
/
flappy.blr
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
int rseed = 26854266;
func int rand(int min, int max) {
rseed = rseed * 3627 + min;
if (rseed < 0) {
rseed = -rseed;
}
return (rseed % (max - min)) + min;
}
/* entity declarations */
entity bird {
clr = (255, 0, 255);
size = (20, 20);
int yspeed = 0;
key_A -> { remove();}
key_UP -> { self.yspeed = 20; }
self >< wall -> { restart(); }
frame -> {
self.yspeed = self.yspeed - 2;
self.pos[1] = self.pos[1] - self.yspeed;
if (self.pos[1] > 400 || self.pos[1] < 0) {
restart();
}
}
}
entity wall {
clr = (0, 0, 0);
size = (20, 420);
frame -> {
self.pos[0] = self.pos[0] - 15;
}
}
entity control {
clr = (0, 0, 0);
size = (0, 0);
int timer = 30;
frame -> {
int gap_size = rand(100, 200);
int gap_height = rand(50, 420 - gap_size - 20);
self.timer = self.timer - 1;
if (self.timer == 0) {
add(wall, (680, -gap_height - gap_size));
add(wall, (680, 420 - gap_height));
self.timer = 30;
}
}
}
/* gameboard declaration */
gameboard g1{
clr = (255,255,255);
size = (680,420);
init -> {
add(bird, (50,150));
add(wall, (680, -250));
add(wall, (680, 300));
add(control, (680, 420));
}
}