-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangrybird.blr
132 lines (109 loc) · 2.35 KB
/
angrybird.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
int rseed = 26854266;
vec birdPos = (100,500);
int maxPigs = 30;
vec cursorPos = (0,0);
func int rand(int min, int max) {
rseed = rseed * 3627 + min;
if (rseed < 0) {
rseed = -rseed;
}
return (rseed % (max - min)) + min;
}
func int flicker(int val) {
int newVal = val+5;
if (newVal > 240) {newVal = 175;}
return newVal;
}
entity bird {
size = (20,20);
clr = (255,0,0);
bool fly = false;
int yspeed = 0;
int xspeed = 0;
key_SPACE -> {
self.fly = true;
self.yspeed = -1*(cursorPos[1]-self.pos[1])/5;
self.xspeed = (cursorPos[0] - self.pos[0])/5;
}
self >< ground -> {remove(); add(bird,birdPos);}
frame -> {
if (self.fly){
self.yspeed = self.yspeed - 5;
self.pos = (self.pos[0]+self.xspeed, self.pos[1] - self.yspeed);
if (self.pos[0]> 900) {remove();add(bird,birdPos);}
}
}
}
entity pig {
size = (25,25);
clr = (0,150,0);
self >< bird -> {remove();}
}
entity cloud {
size = (100,50);
clr = (255,255,255);
frame -> {
self.pos[0] = self.pos[0] -10;
if (self.pos[0] < -100) remove();
}
}
entity sun {
size = (70,70);
clr = (200,255,0);
frame -> {
self.clr[1] = flicker(self.clr[1]);
}
}
entity ground {
size = (860,50);
clr = (0,255,100);
}
entity graphicController {
size = (0,0);
clr = (0,0,0);
int timer = 20;
int cloud_y = 0;
frame -> {
self.timer = self.timer - 1;
if (self.timer == 0) {
self.cloud_y = rand(0,200);
add(cloud, (900,self.cloud_y));
add(cloud,(900+50,self.cloud_y-40));
self.timer = 20;
}
}
}
entity aim1 {
size = (20,5);
clr = (0,0,255);
key_UP -> {self.pos[1]= self.pos[1]-10;}
key_DOWN -> {self.pos[1]= self.pos[1]+10;}
key_LEFT -> {self.pos[0]= self.pos[0]-10;}
key_RIGHT -> {self.pos[0]= self.pos[0]+10;}
frame -> {cursorPos = self.pos;}
}
entity aim2 {
size = (5,20);
clr = (0,0,255);
key_UP -> {self.pos[1]= self.pos[1]-10;}
key_DOWN -> {self.pos[1]= self.pos[1]+10;}
key_LEFT -> {self.pos[0]= self.pos[0]-10;}
key_RIGHT -> {self.pos[0]= self.pos[0]+10;}
}
gameboard g1{
size = (860,600);
clr = (0,200,255);
init -> {
int pigs = 0;
add(graphicController,(-100,-100));
add(ground,(0,550));
add (sun,(10,10));
add(bird,birdPos);
add (aim1, birdPos);
add (aim2,(birdPos[0]+7,birdPos[1]-7));
while (pigs < maxPigs) {
add(pig,(rand(500,860),rand(350,550)));
pigs = pigs + 1;
}
}
}