-
Notifications
You must be signed in to change notification settings - Fork 0
/
pong.blr
63 lines (51 loc) · 1.13 KB
/
pong.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
entity paddle1 {
clr = (255, 255, 255);
size = (10, 100);
key_UP -> {
self.pos[1] = self.pos[1] - 10;
}
key_DOWN -> {
self.pos[1] = self.pos[1] + 10;
}
}
entity paddle2 {
clr = (255, 255, 255);
size = (10, 100);
key_W -> {
self.pos[1] = self.pos[1] - 10;
}
key_S -> {
self.pos[1] = self.pos[1] + 10;
}
}
entity ball {
clr = (255, 255, 255);
size = (10, 10);
int xspeed = 7;
int yspeed = 7;
self >< paddle1 -> {
self.xspeed = -self.xspeed;
}
self >< paddle2 -> {
self.xspeed = -self.xspeed;
}
frame -> {
self.pos[0] = self.pos[0] + self.xspeed;
if (self.pos[0] > 600 - self.size[1] || self.pos[0] < 0 ) {
restart();
}
self.pos[1] = self.pos[1] + self.yspeed;
if (self.pos[1] > 400 - self.size[1] || self.pos[1] < 0) {
self.yspeed = -self.yspeed;
}
}
}
gameboard board {
clr = (0, 0, 0);
size = (600, 400);
init -> {
add(paddle2, (10, 200));
add(paddle1, (580, 200));
add(ball, (300, 300));
}
}