-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8bitBounce.2dpy
executable file
·386 lines (354 loc) · 20.4 KB
/
8bitBounce.2dpy
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
def Init():
# --- author : jamesc
STR.SetFParam0Name("Fade")
STR.SetFParam1Name("Size")
STR.SetFParam2Name("Speed")
GLB.slots = STR.GetMaxSlots()
GLB.xmode = 1
# --- smb tiles - like i always feel compelled to do... 8x8 pixel, four color tile
GLB.tile = [
"0100222201102222111002221111022213111222111112221111122211112222",
"0012222200012222000033220000333200003333100033331111123311112222",
"2221111122211111222011112200011122000002220000222200022222200222",
"2222222222222211222221112222200022220303222203002222003322222233",
"2222222211122222111111223303222233033322333033323300002233333222",
"2222200022223000222331002220011122201111220011122202222022222220",
"0102322200033322000332221111222211112222111222220022222200022222",
"2222211122221111222200032220303322203003222003332222233322000011",
"1122222211111222303222223033322233033322300002223333222200222222",
"3300001133320013332211112221111122111111200111222000222222000222",
"1000333211100332111220221111002211110022211100222222222222222222",
"2222211122221111222200032220303322203003222003332222233322220010",
"2220000122200011222000012221003322221033222221112222200022222000",
"1002222231132222111122223111222211122222000222220000222202222222",
"2222211122201111220000002330330323303300223303332221110022113330",
"1122222211112222303222223333322233003322333002220133222211000222",
"2210333022111330222111112221000122220000202011002000001222000022",
"0000022200000222000022221112222211122222012222222222222222222222",
"2222233311122333111111333303200033033000333033303300000233333022",
"2200000120000000330000003332110123201111220001112000111120221111",
"0001022210001220111112201311310011111100111111001112222222222222",
"2222201022222100222211102200111122001111220011112202200222222022",
"0000333200003322000122221112222211222222222222222222222222222222",
"2222201022222100222211102220111122001111222200112220002222200222",
"0012222200022222000322221003322211233222122232222222222222222222",
"2222200022220000223000012333001122001111222200112220002222200222",
"1002222210022222100222223122222211222222122222222222222222222222",
"2000110000001100000011110000131133331111333311112333111123311111",
"2211111121111112211111222111112222000022220000220000002200000022",
"2003333320003333222003332222133322220100222001002200010020000100",
"0000002230000022333332223302222200102222001002220010002200100002",
"3322131133321111333111112321111222111122220000222200002220000022",
"2220001022000011223301312233311122331111222211122220002222000022",
"2232223223232323232323232323232323232323232323232333233322322232",
"2222222222222111222111111111111122222111222111112222111122222112",
"2211111111111111001100001111100010000000111111111111121121112112",
"2212222211111222110000110033331100000031000111121111222221222222",
"2022222200022222202222222133333321333331213333312133111121333111",
"2222222222222222222222223333322233333222333332221113322211333222",
"2133331121333113213331332133333321222222212222222122222221222222",
"1333322211333222313332223333322222222222222222222222222222222222",
"2200333022003333221103332000103320001000000010000000100000001300",
"3330333330000002330000023333333233300102000001020000110000011000",
"0000111100000111000333111033331113333111213302222200002200000022",
"3333333311111111002222000222221002222210001111000000000011111111",
"2221111122211111222211112222211122222221222222222222222222222222",
"1111222211110200111000001110000011100002220000022222002222222022",
"2221111122211111222211112222111122222111222222222222222222222222",
"1111120011110000111100001111000011110000222222222222222222222222",
"2222222222200222220000222000000220031002003001000030010000300100",
"2222222222201222222012222201112222011122220111222201112222311122",
"2222222222220222222202222222022222220222222202222222022222223222",
"2222222222231222222312222233312222333122223331222233312222333122",
"2211112221100112210030111111030112210001212110111222111222122222",
"2121112222121112122210112211100121100301210030112110011222111122",
"2221221121221111221111101211010122101000211103031101033311100333",
"2222222222221222222221212222111122121010222110302221003322111033",
"2222222222222222222222222222222222222212222212112222211022221100",
"2222222223322222333322223333322223333322223303322333303223333033",
"2233330323233303233333032233303121113331211101012010111021011111",
"2222222222222222222222222222222222222222222222222222333222233033",
"2233330323333303233333333333333133313311331101012010111021011111",
"2222222220222222200222332000233320003311220331113333011133311011",
"2222222222222222222222332222233322223311222331113333011133311011",
"2111110020111011220101112210111122210111222110112222110022222011",
"2222220022222000222200002220000022011000200031002000311100003130",
"0022222200022222000022220000022200011022001300021113000203130000",
"0000333000000000200003332222333322223333222113332221113322221112",
"0333000000000000333000023333222233331122331111123111111221111122",
"2222222222222222222332222232232222322322222332222222222222222222",
"2233332223333302303333303033333030033330330033002333300222000022",
"2222220022222000222200002220000022000000200111002011111000111110",
"0022222201122222111122221111122201110022000000020000000200001100",
"0011111000011100000000002011133322223333222233332222333322222333",
"0000111000000110000000003331110233332222330322223303222230322222",
"2220200222200000221111112111111122111020222100202200000022200000",
"0222222202222222112222221112222211112222010122220101222200011222",
"2211112211111312131133313111331211113312103003000030000030300000",
"2222222222222222222222222222222122222221222222212222211322211113",
"3333333323333333223333332223333322223333222223332222223322222223",
"3333333331111133113131131331331313111313111311131111111333111333",
"2222322222213121221111012113330321311101111111011221110121111121",
"2222322222223222222232222222322222223222222232222222322222223222",
"2213111122200002221311112313111122131111222131212222112122221112",
"2222222222222222222222223333333222222222222222222222222222222222",
"2220002222010102200010000001000100100010010101022000102222010222",
"3333333300000001000000011111111100010000000100000001000011111111",
"0000000100000001000000011111111100010000000100000001000011111111",
"2111111110000000101000001000000010000000100000001000000010000000",
"3103022231230002011222220012222200022222000022220000022210000022",
"2211111121311133231013302311030013101300110113300011113311011113",
"1122222211002222100022221000222200002222000222220022222222222222",
"1110110311110033211333313333111100000011000001120000222200022222",
"3103000231232222011222220012222200122222011222221112222211222222",
"2222222022222220222222002222220022222000200000002000001022000010",
"2222200222222011220011112201113322211331200113112001111122111111",
"2211111120011111200111112221111122011111220011112222201122222002",
"2222221122222110222211102222111122221111222211112222211122222211",
"0000033200000333000003331312222211122220111111001111110011111100",
"2222111022221110222211112221111122211111222111112222111122222111",
"0002222200000332000003331000033311111100111111021111222211222222",
"2222222022220010222201112221111122001331220133112211311120011111",
"2001111122111111220111112200111122211111222201112222001022222220",
"2222222322222223222222002322220020322000200320002000310020003111",
"2222222222222222322222223222232203220322032003220100032211003322",
"2100110321111000111110003331110022333111220033332220002222220022",
"3110011233111333001131120113113111301111330002222000222220022222",
"0222222222222223222222232222220023222200203220002003200020003100",
"2222222222222222222222223222222232222322032203220320032201000322",
"2000311121001103211110001111100033311100223331112000333300002222",
"1100332231100112331113330011311201131131113011113300022222000022",
"2222221122232111233303032330030323300033222000032222030022220333",
"2221113322001100220001102200013122000111222001112222222222222222",
"2223222222333222223330222033102220331002203310022033300220030010",
"2222222222211111221011102211010121331011213101012010111021011111",
"2000000020022000130222001300222211300222113000021030002201330222",
"2010111021110101211110113331010120333110200033332000222222000220",
"1013022211030222111322221133222233302222300022220002222200222222",
"2222222222223222222333222203332220033102200331022003310220033302",
"2222222222222222222111112210111021110101213310112131010120101110",
"2000300020000010220000001200200012002200113002001130020210300222",
"2101111120101110211101012111101133310101223331102000333300002222",
"0133002210130222110302221113222211332222333002223000002222000002",
"2222221122221111222111112211100122110301221100112111111121111111",
"1222222211112222111112221111112211111112111111121111000011100112",
"2111111121111111211111112111111100000111223300012233320022233222",
"1110111211101311111011111110111111003112100332220033322222332222",
"2222222222222211222211112221111122111001221103012211001121111111",
"2222222211222222111122221111122211111122111111121111111211110000",
"2111111121111111211111112111111121111111000001112333000133332200",
"1110011211101112111013111110111111101111110031121003332200233332",
"2222222222223320222333312223333122233331222333332222333322221333",
"2000022200002222111112221113313211333333113313131133131311333333",
"2222111122211111022111110001111100011111200011112000213322022223",
"1113313211111000111100121110012213300122333000023333332233332222",
"2222222222222220222222012222221122333111233333112333333122333333",
"2233333320211111200111112001111122011111220011112220213322222223",
"0022222200022222110022223310222233101222331011223310112211111122",
"2222200022220000222111012213331322133333221331312213313122211101",
"1100011210000012300000123300031233333312333333313133333131333331",
"2220001122000001210000032130003321333333133333331333331313333313",
"1333331313333333131333332133313321333311213333332213333122211112",
"2220002222000001220000032210003321333333133333331333331313333313",
"2222222222222222122222221332222213312202133110201133300011130000",
"2333222222033311220033112210011122111111211111112111110121111000",
"0011000310000232131332322223222222222222222222220322222202222222",
"3111101331111011311110313311100133311003133311001333110033311220",
"0112222223220002200023000000220000000230000002200000023220003222",
"2223111321033113100333131100311311111111111111113331111103311333",
"2222222222222222222223332222203322231001222311112221111122333111",
"0011330011133000111310031113112211331130113311111133111111311111",
"2203311122001111231111113011133322111033233110013331111120013311",
"1331111133111112311111221111102201100332000003330033222230333222",
"2101101121111113211113333333333133333000233000002200003320000033",
"0011003310000232121232320000000200000022111122221222222222222222",
"3111101331111001311111003311110033311110133311111333111133311222",
"1331111133111112311111221111122201100222330000223330033200000333",
"2101101121111111211113333333333133333000233033000000333022222200",
"2222223322223333223111332331113123311311113333111113331111133331",
"1113333311330020233100202022000000020002000011002201111122111100",
"2211100022111000222333332233333321113333131113331111113311111122",
"2222211122221111222111002211100022110003211100332110033321100333",
"2211111121311133231013302311030013101000110100000010000311011113",
"1122222211222222122222221222222202222222022222222222222222222222",
"1101110311110033211333313333111121100011220000002220000022200002",
"1111222231111222111331221133122211331022030000020300000233000002",
"2222222222222221222222232222201122222001222220012222200022211000",
"2222333322333333233300003300011133000111233300002233333322223333",
"2110033321100033211000032111010022111110221111102221121122221221",
"2222113322233333223333332233333323333111211111112111113333333333",
"2222222111122221211122212111122122111121221111212221111122222211",
"2201110022011000222000002221130022113003221033332000000022000000",
"0001122201111222011112221311122233311222003112220031122203111222",
"2222223022222303222230332223303322330333233303333330333322203333",
"2223333322231111222133112223113122231131223133112233003322033333",
"2233233322032032223323322203203222232332222320322223223222222232",
"2223111120333331333333330333033333332332203320322233323222233232",
"2211122221111122110001121111101222111211222222112222221122222211",
"2222221122112211211112112100011110111111111112112222221122222211",
"0030002201322222011222220112222211122222111222221112222211222222",
"2211100021311000231010002311000013101300110113330011111311011113",
"2220001022220000222200002220000022200000222000022200022222002222",
"2222222222122222210332222113222220113322111032220111133211011322",
"1111122210111132111101322011111221101112221111022221011122222101",
"2222222211222222311122221311122211113122111133121111313131111311",
"2222222211211111332133331101111111311111110111111101100111010331",
"3331111133311111331111121111112211111222111122221122222222222222",
"1101033311011133110111131101111111011111112111111121111122222222",
"0022222001002220201002202001002022001020220001002220000022222200",
"2222221222222102222211122222011222211102222111122201011222111112",
"2211101222101112221111022210111222211012222111122222010222222212",
"0022222001002220201002202001002022001020220001002220000022222200",
"2111112222223333222333330000000000333311200111002220000022222200",
"1111111111111111300000323322233233222332300000321111111111111111",
"1111111111111111222223322222203222220022222002222300222223322222",
"1111111111111111222223322222203222222022222220222222022222220222",
"2222022222202222223022222233222222332222223022222220222222220222",
"2111111122111111221111102211110322211110222211112222221122222222",
"2222220022220001000001112111111121111111211111112111111121111111",
"2232223223322323223223232232232322322323223223232333233323332232",
"2332223232232323222323232232232323222323322223233333233333332232",
"3232223232322323323223233232232333332323333323232232233322322232",
"3333223232222323322223233332232322232323222323233333233333322232",
"2332223232232323232323232332232332332323322323233223233323322232",
"2232222223232222232322222323222223232222232322222333222222322222",
"2222222222222222222222222222222222222222222222222222222222222222",
"2332233233322332233223322332233223322332233223333333223322222222",
"2323333223233223232332232323322323233332332332223223322222222222",
"2222222222222222222222222222222222222222211110222211022222222222",
"2211122221221122112221121122211211222112211221222211122222222222",
"2221122222111222222112222221122222211222222112222111111222222222",
"2111112211222112222211122211112221111222111222221111111222222222",
"2111111222221122222112222211112222222112112221122111112222222222",
"2221112222111122211211221122112211111112222211222222112222222222",
"1111112211222222111111222222211222222112112221122111112222222222",
"2211112221122222112222221111112211222112112221122111112222222222",
"1111111211222112222211222221122222112222221122222211222222222222",
"2111112211222112112221122111112211222112112221122111112222222222",
"2111112211222112112221122111111222222112222211222111122222222222",
"2211122221121122112221121122211211111112112221121122211222222222",
"1111112211222112112221121111112211222112112221121111112222222222",
"2211112221122112112222221122222211222222211221122211112222222222",
"1111122211221122112221121122211211222112112211221111122222222222",
"1111111211222222112222221111112211222222112222221111111222222222",
"1111111211222222112222221111112211222222112222221122222222222222",
"2211111221122222112222221122111211222112211221122211111222222222",
"1122211211222112112221121111111211222112112221121122211222222222",
"2111111222211222222112222221122222211222222112222111111222222222",
"2221111222222112222221122222211211222112112221122111112222222222",
"1122211211221122112112221111222211111222112111221122111222222222",
"2112222221122222211222222112222221122222211222222111111222222222",
"1122211211121112111111121111111211212112112221121122211222222222",
"1122211211122112111121121111111211211112112211121122211222222222",
"2111112211222112112221121122211211222112112221122111112222222222",
"1111112211222112112221121122211211111122112222221122222222222222",
"2111112211222112112221121122211211211112112211222111121222222222",
"1111112211222112112221121122111211111222112111221122111222222222",
"2111122211221122112222222111112222222112112221122111112222222222",
"2111111222211222222112222221122222211222222112222221122222222222",
"1122211211222112112221121122211211222112112221122111112222222222",
"1122211211222112112221121112111221111122221112222221222222222222",
"1122211211222112112121121111111211111112111211121122211222222222",
"1122211211121112211111222211122221111122111211121122211222222222",
"2112211221122112211221122211112222211222222112222221122222222222",
"1111111222221112222111222211122221112222111222221111111222222222",
"2222222222222222222222222222222222222222222222222222222222222222",
"1111111111111111111111111111111111111111111111111111111111111111",
"3333333333333333333333333333333333333333333333333333333333333333",
"0000000000000000000000000000000000000000000000000000000000000000",
"2222222222222222222222222111111221111112222222222222222222222222",
"2222222222222222212221222212122222212222221212222122212222222222",
"1000000010000000100000001000000010000000100000001000000010000000",
"2221122222111122221111222211112222211222222112222222222222211222",
"0000000031111111311111113111111131111111111111111113331111333331",
"1333333313333333133333331133333111133311111111111111111100000000",
"2211022221111022211110222111102221111022211110222211022222222222" ]
GLB.tile_index = 0
# --- clear screen
cr.set_source_rgba(0,0,0,1)
cr.rectangle(0,0,320,240)
cr.fill()
# --- track trigger
GLB.xmode = 1 # --- force on grid
# --- speed control
GLB.timer_max = 30
GLB.timer = 0
def gen_rnd_palette():
r = [np.random.random(), np.random.random(), np.random.random(), np.random.random()]
g = [np.random.random(), np.random.random(), np.random.random(), np.random.random()]
b = [np.random.random(), np.random.random(), np.random.random(), np.random.random()]
return r, g, b
GLB.gen_rnd_palette = gen_rnd_palette
# --- global palette
GLB.r, GLB.g, GLB.b = GLB.gen_rnd_palette()
def drawTile(x, y, scale, tile,r,g,b, a): # --- add pallete later
myindx = 0
row = 7
col = 0
for i in range(len(tile)):
xpos = x + (col * scale)
ypos = y + (row * scale)
color_index = int(tile[myindx:myindx+1])
myindx+=1
draw_pixel = 1
if ( xpos < 320) and ( ypos < 240) :
if (a) and (int(color_index == 2) ):
draw_pixel = 0
if (draw_pixel):
cr.set_source_rgb(r[color_index], g[color_index], b[color_index] )
cr.rectangle(xpos, ypos, scale, scale)
cr.fill()
col+=1
if (col > 7):
row-=1
col =0
GLB.drawTile = drawTile
def update(objs, f1, f2, a, xmode):
for i in range(12):
cr.set_line_width(f1 * 8.0 + 2.)
cr.set_line_cap(cairo.LINE_CAP_ROUND)
if (xmode):
cr.set_source_rgb(objs[i]['b'], objs[i]['g'], objs[i]['r'])
else :
cr.set_source_rgb(1, 1, 1)
cr.move_to(objs[i]['xpos'], objs[i]['ypos'])
if (i == 11) :
cr.curve_to(objs[0]['bp1x'], objs[0]['bp1y'], objs[0]['bp2x'], objs[0]['bp2y'],objs[0]['xpos'], objs[0]['ypos'] )
else :
cr.curve_to(objs[i+1]['bp1x'], objs[i+1]['bp1y'], objs[i+1]['bp2x'], objs[i+1]['bp2y'],objs[i+1]['xpos'], objs[i+1]['ypos'] )
cr.stroke()
GLB.update = update
def Render(cr):
# ---- clear screen
acc = STR.CheckAccent()
trig = STR.CheckTrigger()
f0 = STR.F0()
f1 = STR.F1()
f2 = STR.F2()
# ---- clear screen
cr.set_source_rgba(0,0,0,f0)
cr.rectangle(0,0,320,240)
cr.fill()
scale = f1 * 8 + 2
if trig:
GLB.xmode = 1 if GLB.xmode==0 else 0
if (GLB.timer > GLB.timer_max) :
GLB.tile_index = np.random.randint(0, len(GLB.tile))
# --- use global palette
r = GLB.r
g = GLB.g
b = GLB.b
if (GLB.xmode) :
scale = int(scale)
grid_x = ( 320 / (scale * 8) ) + 1
grid_y = ( 240 / (scale * 8) ) + 1
myx = np.random.randint(0,grid_x) * scale * 8
myy = np.random.randint(0,grid_y) * scale * 8
else:
grid_x = ( 320 / scale ) + 1
grid_y = ( 240 / scale ) + 1
myx = np.random.randint(0,grid_x) * scale
myy = np.random.randint(0,grid_y) * scale
GLB.drawTile(myx,myy ,scale,GLB.tile[GLB.tile_index],r,g,b,acc )
GLB.timer = 0
GLB.timer = GLB.timer+ (10*f2)