-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbreakout2.led
120 lines (97 loc) · 5.18 KB
/
breakout2.led
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
Define colors used in the game
/-----------------------------------------------------------------------------------------------
Black := color(0, 0, 0)
Red := color(255, 0, 0)
Orange := color(255, 128, 0)
Yellow := color(255, 255, 0)
Green := color(0, 255, 0)
Blue := color(0, 0, 255)
Indigo := color(70, 0, 130)
Violet := color(148, 0, 211)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
point(x,y) :=
(x,y)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
color(r,g,b) :=
(r,g,b)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
click(cl,p) :=
(cl,p)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
input(cl,k) :=
(cl,k)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
text(s,p,n,c) :=
(`txt,s,p,n,c)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
paddle(tl,tr,bl,br) :=
(tl,tr,bl,br)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
segment(p,r,c) :=
(`seg,p,r,c)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
triangle(p,q,r) :=
(`fTri,p,q,r,Orange)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
disc(p,r,c) :=
(`disc,p,r,c)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
DisplayWidth :=1000
DisplayHeight :=800
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
BrickWidth := 100
BrickHeight :=40
BallRadius :=10
------------------------------------------------------------------------------------------------/
A *brick* consists of two filled triangles
/-----------------------------------------------------------------------------------------------
brick(tl,tr,bl,br) :=
{tri1,tri2} where tri1=triangle(tl,tr,br) & tri2=triangle(tl,bl,br)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
yRow(n) :=
DisplayHeight-(n-1)*BrickHeight
xRow(n):=
DisplayWidth - (n-1)*BrickWidth
Row :=
Union [x in {0 .. DisplayWidth/BrickWidth-1}]{x*BrickWidth}
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
initialRow(y) :=
Union[x in Row]{buildTopTri(x,y)} U Union[x in Row]{buildBotTri(x,y)}
buildTopTri(x,y):=
triangle(p,q,r) where p=(x,y) & q = (x+BrickWidth,y) & r =(x+BrickWidth,y-BrickHeight)
buildBotTri(x,y):=
triangle(p,q,r) where p=(x,y) & q=(x,y-BrickHeight) & r = (x+BrickWidth,y-BrickHeight)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
initialState :=
{}
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
images(S) :=
initialWall U initialSeperators(3,10)
initialWall:=
initialRow(yRow(1)) U initialRow(yRow(2)) U initialRow(yRow(3))
rowSeperators(r,c):=
Union[x in {0..r+1}]{segment((0,yRow(x)),(DisplayWidth,yRow(x)),Black)}
columnSeperator(r,c):=
Union[y in {0..c}]{segment((xRow(y),DisplayHeight),(xRow(y),yRow(r+1)),Black)}
initialSeperators(r,c):=
rowSeperators(r,c) U columnSeperator(r,c)
------------------------------------------------------------------------------------------------/
/-----------------------------------------------------------------------------------------------
transition(I,S) :=
{}
------------------------------------------------------------------------------------------------/