-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtui-cat.red
576 lines (473 loc) · 19.2 KB
/
tui-cat.red
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
Red [
Title: "TUI-PAC"
Needs: 'View
Config: [GUI-engine: 'terminal]
Description: {A Pacman clone made to test Red TUI (Text User Interface) Engine}
Author: "Giuseppe Chillemi"
Copyright: "To Be defined"
TBD: {
Redo the engine to keep on the central way and not on lateral space
Fix the uncentered PAC
Add lateral walls trepassing management
Add ghosts
Add Big Pill management
Add hi-score
Save Hi-Score
Add level editor
Add "hidden" playmode
Make the path engine able to handle all
mazes
Toggle debug informations
}
notes: {
maze taken from here:
https://codeberg.org/NNB/ansi/ (This resource is full of links!!!)
that has also been taken from
https://www.reddit.com/r/unixporn/comments/jisfcx/oc_pacman_prompt_anyone/
}
LOG: {
Changed the name to TUI-PAC
}
]
maze-binary: #{
1B5B33346DE29594E29590E29590E29590E29590E29590E29590E29590E29590
E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E295
90E29590E29590E29590E29590E29590E29590E295A4E29590E295A4E29590E2
9590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590
E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E295
90E29590E29590E295971B5B306D0A1B5B33346DE295911B5B33336D20E280A2
20E280A220E280A220E280A220E280A220E280A220E280A220E280A220E280A2
20E280A220E280A220E280A2201B5B33346DE2948220E294821B5B33336D20E2
80A220E280A220E280A220E280A220E280A220E280A220E280A220E280A220E2
80A220E280A220E280A220E280A2201B5B33346DE295911B5B306D0A1B5B3334
6DE295911B5B33336D20E280A2201B5B33346DE2948CE29480E29480E29480E2
9480E29480E294901B5B33336D20E280A2201B5B33346DE2948CE29480E29480
E29480E29480E29480E29480E29480E294901B5B33336D20E280A2201B5B3334
6DE2948220E294821B5B33336D20E280A2201B5B33346DE2948CE29480E29480
E29480E29480E29480E29480E29480E294901B5B33336D20E280A2201B5B3334
6DE2948CE29480E29480E29480E29480E29480E294901B5B33336D20E280A220
1B5B33346DE295911B5B306D0A1B5B33346DE295911B5B33336D20E2978F201B
5B33346DE294822020202020E294821B5B33336D20E280A2201B5B33346DE294
8220202020202020E294821B5B33336D20E280A2201B5B33346DE2948220E294
821B5B33336D20E280A2201B5B33346DE2948220202020202020E294821B5B33
336D20E280A2201B5B33346DE294822020202020E294821B5B33336D20E2978F
201B5B33346DE295911B5B306D0A1B5B33346DE295911B5B33336D20E280A220
1B5B33346DE29494E29480E29480E29480E29480E29480E294981B5B33336D20
E280A2201B5B33346DE29494E29480E29480E29480E29480E29480E29480E294
80E294981B5B33336D20E280A2201B5B33346DE29494E29480E294981B5B3333
6D20E280A2201B5B33346DE29494E29480E29480E29480E29480E29480E29480
E29480E294981B5B33336D20E280A2201B5B33346DE29494E29480E29480E294
80E29480E29480E294981B5B33336D20E280A2201B5B33346DE295911B5B306D
0A1B5B33346DE295911B5B33336D20E280A220E280A220E280A220E280A220E2
80A220E280A220E280A220E280A220E280A220E280A220E280A220E280A220E2
80A220E280A220E280A220E280A220E280A220E280A220E280A220E280A220E2
80A220E280A220E280A220E280A220E280A220E280A2201B5B33346DE295911B
5B306D0A1B5B33346DE295911B5B33336D20E280A2201B5B33346DE2948CE294
80E29480E29480E29480E29480E294901B5B33336D20E280A2201B5B33346DE2
948CE29480E294901B5B33336D20E280A2201B5B33346DE2948CE29480E29480
E29480E29480E29480E29480E29480E29480E29480E29480E29480E29480E294
80E294901B5B33336D20E280A2201B5B33346DE2948CE29480E294901B5B3333
6D20E280A2201B5B33346DE2948CE29480E29480E29480E29480E29480E29490
1B5B33336D20E280A2201B5B33346DE295911B5B306D0A1B5B33346DE295911B
5B33336D20E280A2201B5B33346DE29494E29480E29480E29480E29480E29480
E294981B5B33336D20E280A2201B5B33346DE2948220E294821B5B33336D20E2
80A2201B5B33346DE29494E29480E29480E29480E29480E29480E2949020E294
8CE29480E29480E29480E29480E29480E294981B5B33336D20E280A2201B5B33
346DE2948220E294821B5B33336D20E280A2201B5B33346DE29494E29480E294
80E29480E29480E29480E294981B5B33336D20E280A2201B5B33346DE295911B
5B306D0A1B5B33346DE295911B5B33336D20E280A220E280A220E280A220E280
A220E280A220E280A2201B5B33346DE2948220E294821B5B33336D20E280A220
E280A220E280A220E280A2201B5B33346DE2948220E294821B5B33336D20E280
A220E280A220E280A220E280A2201B5B33346DE2948220E294821B5B33336D20
E280A220E280A220E280A220E280A220E280A220E280A2201B5B33346DE29591
1B5B306D0A1B5B33346DE2959AE29590E29590E29590E29590E29590E29590E2
9590E29590E29590E295971B5B33336D20E280A2201B5B33346DE2948220E294
94E29480E29480E29480E29480E29480E294901B5B33336D20E280A2201B5B33
346DE2948220E294821B5B33336D20E280A2201B5B33346DE2948CE29480E294
80E29480E29480E29480E2949820E294821B5B33336D20E280A2201B5B33346D
E29594E29590E29590E29590E29590E29590E29590E29590E29590E29590E295
9D1B5B306D0A1B5B33346D20202020202020202020E295911B5B33336D20E280
A2201B5B33346DE2948220E2948CE29480E29480E29480E29480E29480E29498
1B5B33336D20E280A2201B5B33346DE29494E29480E294981B5B33336D20E280
A2201B5B33346DE29494E29480E29480E29480E29480E29480E2949020E29482
1B5B33336D20E280A2201B5B33346DE295911B5B306D0A1B5B33346D20202020
202020202020E295911B5B33336D20E280A2201B5B33346DE2948220E294821B
5B33336D20E280A220E280A220E280A220E280A220E280A220E280A220E280A2
20E280A220E280A220E280A2201B5B33346DE2948220E294821B5B33336D20E2
80A2201B5B33346DE295911B5B306D0A1B5B33346D20202020202020202020E2
95911B5B33336D20E280A2201B5B33346DE2948220E294821B5B33336D20E280
A2201B5B33346DE29594E29590E29590E29590E29590E295901B5B306DE29481
E29481E294811B5B33346DE29590E29590E29590E29590E29590E295971B5B33
336D20E280A2201B5B33346DE2948220E294821B5B33336D20E280A2201B5B33
346DE295911B5B306D0A1B5B33346DE29590E29590E29590E29590E29590E295
90E29590E29590E29590E29590E2959D1B5B33336D20E280A2201B5B33346DE2
9494E29480E294981B5B33336D20E280A2201B5B33346DE29591202020202020
20202020202020E295911B5B33336D20E280A2201B5B33346DE29494E29480E2
94981B5B33336D20E280A2201B5B33346DE2959AE29590E29590E29590E29590
E29590E29590E29590E29590E29590E295901B5B306D0A1B5B33346D20202020
202020202020201B5B33336D20E280A220E280A220E280A220E280A2201B5B33
346DE2959120202020202020202020202020E295911B5B33336D20E280A220E2
80A220E280A220E280A21B5B306D0A1B5B33346DE29590E29590E29590E29590
E29590E29590E29590E29590E29590E29590E295971B5B33336D20E280A2201B
5B33346DE2948CE29480E294901B5B33336D20E280A2201B5B33346DE2959120
202020202020202020202020E295911B5B33336D20E280A2201B5B33346DE294
8CE29480E294901B5B33336D20E280A2201B5B33346DE29594E29590E29590E2
9590E29590E29590E29590E29590E29590E29590E295901B5B306D0A1B5B3334
6D20202020202020202020E295911B5B33336D20E280A2201B5B33346DE29482
20E294821B5B33336D20E280A2201B5B33346DE2959AE29590E29590E29590E2
9590E29590E29590E29590E29590E29590E29590E29590E29590E29590E2959D
1B5B33336D20E280A2201B5B33346DE2948220E294821B5B33336D20E280A220
1B5B33346DE295911B5B306D0A1B5B33346D20202020202020202020E295911B
5B33336D20E280A2201B5B33346DE2948220E294821B5B33336D20E280A220E2
80A220E280A220E280A220E280A220E280A220E280A220E280A220E280A220E2
80A2201B5B33346DE2948220E294821B5B33336D20E280A2201B5B33346DE295
911B5B306D0A1B5B33346D20202020202020202020E295911B5B33336D20E280
A2201B5B33346DE2948220E294821B5B33336D20E280A2201B5B33346DE2948C
E29480E29480E29480E29480E29480E29480E29480E29480E29480E29480E294
80E29480E29480E294901B5B33336D20E280A2201B5B33346DE2948220E29482
1B5B33336D20E280A2201B5B33346DE295911B5B306D0A1B5B33346DE29594E2
9590E29590E29590E29590E29590E29590E29590E29590E29590E2959D1B5B33
336D20E280A2201B5B33346DE29494E29480E294981B5B33336D20E280A2201B
5B33346DE29494E29480E29480E29480E29480E29480E2949020E2948CE29480
E29480E29480E29480E29480E294981B5B33336D20E280A2201B5B33346DE294
94E29480E294981B5B33336D20E280A2201B5B33346DE2959AE29590E29590E2
9590E29590E29590E29590E29590E29590E29590E295971B5B306D0A1B5B3334
6DE295911B5B33336D20E280A220E280A220E280A220E280A220E280A220E280
A220E280A220E280A220E280A220E280A220E280A220E280A2201B5B33346DE2
948220E294821B5B33336D20E280A220E280A220E280A220E280A220E280A220
E280A220E280A220E280A220E280A220E280A220E280A220E280A2201B5B3334
6DE295911B5B306D0A1B5B33346DE295911B5B33336D20E280A2201B5B33346D
E2948CE29480E29480E29480E29480E29480E294901B5B33336D20E280A2201B
5B33346DE2948CE29480E29480E29480E29480E29480E29480E29480E294901B
5B33336D20E280A2201B5B33346DE2948220E294821B5B33336D20E280A2201B
5B33346DE2948CE29480E29480E29480E29480E29480E29480E29480E294901B
5B33336D20E280A2201B5B33346DE2948CE29480E29480E29480E29480E29480
E294901B5B33336D20E280A2201B5B33346DE295911B5B306D0A1B5B33346DE2
95911B5B33336D20E280A2201B5B33346DE29494E29480E29480E29480E29490
20E294821B5B33336D20E280A2201B5B33346DE29494E29480E29480E29480E2
9480E29480E29480E29480E294981B5B33336D20E280A2201B5B33346DE29494
E29480E294981B5B33336D20E280A2201B5B33346DE29494E29480E29480E294
80E29480E29480E29480E29480E294981B5B33336D20E280A2201B5B33346DE2
948220E2948CE29480E29480E29480E294981B5B33336D20E280A2201B5B3334
6DE295911B5B306D0A1B5B33346DE295911B5B33336D20E2978F201B5B33336D
E280A220E280A2201B5B33346DE2948220E294821B5B33336D20E280A220E280
A220E280A220E280A220E280A220E280A220E280A22020202020E280A220E280
A220E280A220E280A220E280A220E280A220E280A2201B5B33346DE2948220E2
94821B5B33336D20E280A220E280A220E2978F201B5B33346DE295911B5B306D
0A1B5B33346DE2959FE29480E29480E29480E294901B5B33336D20E280A2201B
5B33346DE2948220E294821B5B33336D20E280A2201B5B33346DE2948CE29480
E294901B5B33336D20E280A2201B5B33346DE2948CE29480E29480E29480E294
80E29480E29480E29480E29480E29480E29480E29480E29480E29480E294901B
5B33336D20E280A2201B5B33346DE2948CE29480E294901B5B33336D20E280A2
201B5B33346DE2948220E294821B5B33336D20E280A2201B5B33346DE2948CE2
9480E29480E29480E295A21B5B306D0A1B5B33346DE2959FE29480E29480E294
80E294981B5B33336D20E280A2201B5B33346DE29494E29480E294981B5B3333
6D20E280A2201B5B33346DE2948220E294821B5B33336D20E280A2201B5B3334
6DE29494E29480E29480E29480E29480E29480E2949020E2948CE29480E29480
E29480E29480E29480E294981B5B33336D20E280A2201B5B33346DE2948220E2
94821B5B33336D20E280A2201B5B33346DE29494E29480E294981B5B33336D20
E280A2201B5B33346DE29494E29480E29480E29480E295A21B5B306D0A1B5B33
346DE295911B5B33336D20E280A220E280A220E280A220E280A220E280A220E2
80A2201B5B33346DE2948220E294821B5B33336D20E280A220E280A220E280A2
20E280A2201B5B33346DE2948220E294821B5B33336D20E280A220E280A220E2
80A220E280A2201B5B33346DE2948220E294821B5B33336D20E280A220E280A2
20E280A220E280A220E280A220E280A2201B5B33346DE295911B5B306D0A1B5B
33346DE295911B5B33336D20E280A2201B5B33346DE2948CE29480E29480E294
80E29480E29480E29480E29480E29480E29480E2949820E29494E29480E29480
E29480E29480E29480E294901B5B33336D20E280A2201B5B33346DE2948220E2
94821B5B33336D20E280A2201B5B33346DE2948CE29480E29480E29480E29480
E29480E2949820E29494E29480E29480E29480E29480E29480E29480E29480E2
9480E29480E294901B5B33336D20E280A2201B5B33346DE295911B5B306D0A1B
5B33346DE295911B5B33336D20E280A2201B5B33346DE29494E29480E29480E2
9480E29480E29480E29480E29480E29480E29480E29480E29480E29480E29480
E29480E29480E29480E29480E294981B5B33336D20E280A2201B5B33346DE294
94E29480E294981B5B33336D20E280A2201B5B33346DE29494E29480E29480E2
9480E29480E29480E29480E29480E29480E29480E29480E29480E29480E29480
E29480E29480E29480E29480E294981B5B33336D20E280A2201B5B33346DE295
911B5B306D0A1B5B33346DE295911B5B33336D20E280A220E280A220E280A220
E280A220E280A220E280A220E280A220E280A220E280A220E280A220E280A220
E280A220E280A220E280A220E280A220E280A220E280A220E280A220E280A220
E280A220E280A220E280A220E280A220E280A220E280A220E280A2201B5B3334
6DE295911B5B306D0A1B5B33346DE2959AE29590E29590E29590E29590E29590
E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E295
90E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E2
9590E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590
E29590E29590E29590E29590E29590E29590E29590E29590E29590E29590E295
90E29590E29590E29590E29590E29590E2959D1B5B306D0A
}
ctx-maze: make object! [
the-maze: copy maze-binary
maze: none
Start-time: none
last-time: none
record-time: none
;--- Characters, unused in the source but listed here for personal preference
esc: #{1B}
open-square: #{5B}
zer: #{30} ;0
emme: #{6D} ;m
agrave: #{E2}
escape-agrave: rejoin [#{1B} #{E2}] ;escape-paren
escape-paren: rejoin [#{1B} #{5B}] ;????
;--- From here on we use all elements
;--- Walls
double-h: rejoin [#{E2} #{95} #{90}] ;double horizontal line
double-v: rejoin [#{E2} #{95} #{91}] ;double vertical line line
double-ul: rejoin [#{E2} #{95} #{94}] ;double upper left angle
double-ur: rejoin [#{E2} #{95} #{97}] ;double upper right angle
double-lr: rejoin [#{E2} #{95} #{9D}] ;double lower right angle
double-lowerleft: rejoin [#{E2} #{95} #{9A}] ;double lower left angle
double-t-down: rejoin [#{E2} #{95} #{A4}] ;double line T point down
;double-t-up: rejoin [#{E2} #{95} #{A4}]; double line T point up
double-t-right: rejoin [#{E2} #{95} #{9F}] ;double line T right direction
double-t-left: rejoin [#{E2} #{95} #{A2}] ;double line T left direction
single-h: rejoin [#{e2} #{94} #{80}] ; horizontal line
single-h2: rejoin [#{e2} #{94} #{81}] ; horizontal line2
single-v: rejoin [#{e2} #{94} #{82}] ; vertical line
single-ur: rejoin [#{e2} #{94} #{90}] ; upper right angle
single-lr: rejoin [#{e2} #{94} #{98}] ; lower right angle
single-ul: rejoin [#{e2} #{94} #{8c}] ; upper left angle
single-ll: rejoin [#{e2} #{94} #{94}] ; lower left angle
;--- This is the parse rule containing all the elements we can't walk over
walls-p: [
double-h |
double-v |
double-ul |
double-ur |
double-lr |
double-lowerleft |
double-t-down |
double-t-right |
double-t-left |
single-h |
single-h2 |
single-v |
single-ur |
single-lr |
single-ul |
single-ll
]
;== Commands
;--- Colors - Neutral
ye: rejoin [#{1B} #{5B} #{33} #{34} #{6D}]
bl: rejoin [#{1B} #{5B} #{33} #{33} #{6D}]
linefeed: #{0A}
reset: rejoin [#{1B} #{5B} #{30} #{6D}]
;---The parse rule for those commands
neutral-p: [ye | bl | reset]
;--- Allowed
;--- Pac cat can wolk over all there characters
spc1: #{20} ;space
big-dot: rejoin [#{e2} #{97} #{8f}] ;big dot
dot: rejoin [#{e2} #{80} #{a2}] ;
;--- The rule tu match them
allowed-p: [spc1 | big-dot | dot]
;A simple test I can manualli use, so the if the rules matches alle the elements, returns true.
; It means every single combination of the maze is parsed
; note: longest rules first
;
test-rules: does [
probe parse the-maze [some [ walls-p | allowed-p | neutral-p | linefeed ] end]
]
;Counter of dots left in the map
dots-count: 0
;---Here we extract dot count and build map of all the elements we can walk on
;
;---ANSI Maze works this way:
; We have solid elements and commands
; each line has element until line feed
; We create a map made of lines and solid alements with ù
; their index on screen and also on the original binary
process-maze: func [
/local
idx
line-pos
line
mapp
pos-solid
;rounds-in
;rounds-out
;append-line?
x
y
incx
incy
decx
decy
inc-dots-count
] [
;rounds-in: 0
;rounds-out: 0
x: 0
y: 0
incx: does [x: x + 1]
decx: does [x: x - 1]
incy: does [y: y + 1]
decy: does [y: y - 1]
inc-dots-count: does [dots-count: dots-count + 1]
mapp: copy [
;Structure:
;[maze-pos pos]
;
]
line: copy []
parse the-maze [
some [
some [ walls-p (incx) | pos-solid: allowed-p (append line reduce [incx index? pos-solid]) | neutral-p ]
line-pos: linefeed
(
if true [append/only mapp line x: 0]
line: copy []
)
]
end
]
dots-count: 0
;---Extracting the dots count
;
parse the-maze [any [dot (inc-dots-count) | big-dot (inc-dots-count) | skip] to end]
maze: mapp
]
; The starting pos of PAC CAT
pac-pos: 20x20
match-value: func [
"If the input matches the value at the starting point returns true"
series [string! binary! issue!]
value [string! binary! issue!]
/local
ln
] [
ln: length? value
series: copy/part series ln
either value = series [true] [false]
]
move-pac: func [
direction
/local
x
y
selected
next-pac-pos
] [
switch direction [
left [next-pac-pos: paccat/offset - 1x0]
right [next-pac-pos: paccat/offset + 1x0]
up [next-pac-pos: paccat/offset - 0x1]
down [next-pac-pos: paccat/offset + 0x1]
]
insert clear head xpos/text to-string to-integer first paccat/offset
insert clear head ypos/text to-string to-integer second paccat/offset
x: to-integer first next-pac-pos
y: to-integer second next-pac-pos
insert clear head next-pos/text to-string next-pac-pos
insert clear head nextxpos/text to-string x
insert clear head nextypos/text to-string y
if selected: select/skip maze/(y + 1) (x + 1) 2 [
paccat/offset: next-pac-pos
insert clear head maze-selected/text to-string selected
insert clear head ascii-selected/text mold copy/part at the-maze selected 15
if parse at the-maze selected [1 [dot | big-dot] to end] [
ln-dot: length? dot
remove/part at the-maze selected ln-dot
insert at the-maze selected spc1
insert clear head board/text to-string head the-maze
the-maze: head the-maze
;--For debugging purpose
;
;write %modified-maze.ansi head the-maze
]
process-maze
insert clear head dotsc/text to-string dots-count
if dots-count = 0 [
view me: layout/tight [
on-key [
case [
any [event/key = #"y" event/key = #"Y"] [unview/all start-pac]
any [event/key = #"n" event/key = #"N"] [unview/all quit]
]
]
origin 13x10
Style text3: text 35x1 blue
below
text3 "You won!!! You are Fantastic!"
Text3 ""
Text3 "" with [
text: rejoin ["Completed in: " last-time: now/time - start-time]
]
Text3 ""
Text3 "A giant THANK YOU to"
Text3 "the Red team for the TUI engine"
Text3 ""
Text3 "Restart Y/N" red font-color white
]
;--- Print here in the middle of the base
]
]
]
]
start-pac: does [
;Coping is needed when the game is restarted
;
ctx-maze/the-maze: copy maze-binary
ctx-maze/start-time: now/time
;--- TBD: Move this inside the object
;
either ctx-maze/record-time [
if ctx-maze/last-time < ctx-maze/record-time [ctx-maze/record-time: ctx-maze/last-time]
] [
ctx-maze/record-time: ctx-maze/last-time
]
;---Here we process the map, see the object member for a description of the process
;
ctx-maze/process-maze
page-0: layout/tight [
;--- Setting events
on-key [
switch event/key [
left [
ctx-maze/move-pac 'left
]
right [
ctx-maze/move-pac 'right
]
up [
ctx-maze/move-pac 'up
]
down [
ctx-maze/move-pac 'down
]
;--Reset the position
#"t" [paccat/offset: 1x1]
#"q" [unview/all]
]
]
panel 70x60 [
board: base 60x60 transparent with [text: to-string ctx-maze/the-maze]
]
panel 40x40 [
style text: text 30x1
style ltext: text 15x1
across
ltext "Current" blue current-pos: text "" return
ltext "Now XPOS" xpos: text "" return
ltext "Now YPOS" ypos: text "" return
text "Requested positions" red return
ltext "Next Pos: " next-pos: text "" return
ltext "Next XPOS" nextxpos: text "" return
ltext "Next YPOS" nextypos: text "" return
ltext "Sel on Maze:" maze-selected: text "---" return
ltext "BIN STREAM:" ascii-selected: text "xxxxxxxxxx" return
ltext "" return
ltext "Dots-count:" DOTSC: text 5x1 data ctx-maze/dots-count brown return
ltext "" return
ltext "Last Time:" LAST-TIME: text 15x1 data ctx-maze/last-time blue return
ltext "Record:" RECORD-TIME: text 15x1 data ctx-maze/record-time return
ltext "" return
ltext "Press Q to quit" magenta return
]
origin 20x20 space 1x1
paccat: base transparent 2x1 "🐱"
]
view page-0
]
start-pac