-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbreakout.css
1804 lines (1659 loc) · 58.1 KB
/
breakout.css
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
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@import url("https://unpkg.com/css-screensize@1/screensize.css");
@import url("https://unpkg.com/[email protected]/bin-bits.css");
* {
box-sizing: border-box;
font-family: sans-serif;
margin: 0px;
padding: 0px;
}
html, body, .game, .board { height: 100%; }
body, .game { display: grid; overflow: hidden; accent-color: var(--c2-out); }
.game {
/* IO Sequence State Identifiers */
--CLOCK: 0;
--START_GAME: 10;
--RESPAWN: 15;
--SET_PALETTE: 20;
--NEXT_LEVEL_PROMPT: 25; /* after all bricks on all lines cleared */
--NEXT_LEVEL: 30;
--GAME_COMPLETE: calc(var(--SET_PALETTE) + var(--NEXT_LEVEL_PROMPT)); /* 45 */
--GAME_OVER: 100;
--infinite-lives: 0;
--zero-deaths: 0;
--rip-through-mode: 0;
--cheats-active-in: 0;
--cheats-active-out: calc(
var(--cheats-active-in) +
(1 - var(--cheats-active-in)) * min(1,
var(--infinite-lives) + var(--zero-deaths) + var(--rip-through-mode)
)
);
--constrain: 1;
--rows: calc(6 * 8 * 2);
--cols: calc(14 * 4);
--max-h: max(240,
(1 - var(--constrain)) * var(--height) +
var(--constrain) * min(
var(--height),
var(--width) / var(--cols) * var(--rows)
)
);
--max-w: calc(
var(--max-h) / var(--rows) * var(--cols) * var(--constrain) +
max(240 / var(--rows) * var(--cols), var(--width)) * (1 - var(--constrain))
);
--row-h: calc(var(--max-h) / var(--rows) * 1px);
--col-w: calc(var(--max-w) / var(--cols) * 1px);
--scaleX: calc(
(var(--max-w) / var(--cols)) / (var(--max-h) / var(--rows))
);
--frame-in: 0;
--frame-out: var(--frame-in);
--seq-in: var(--START_GAME);
--seq-out: var(--seq-in);
--palette-in: 0;
--palette-out: var(--palette-in);
--level-in: 0;
--level-out: var(--level-in);
--lives-in: 3;
--lives-out: var(--lives-in);
--brokethrough-in: 0;
--brokethrough-out: var(--brokethrough-in);
--broke-at-in: 0;
--broke-at-out: var(--broke-at-in);
--points-total-in: 0;
--points-total-out: var(--points-total-in);
--test-in: 0;
--test-out: var(--test-in);
--can-break-in: 1;
--can-break-out: var(--can-break-in);
--can-guide-in: 1;
--can-guide-out: var(--can-guide-in);
--FULL_ROW: 16383; /* 0b 11 11 11 11 11 11 11 */
--r7: var(--FULL_ROW);
--r6: var(--FULL_ROW);
--r5: var(--FULL_ROW);
--r4: var(--FULL_ROW);
--r3: var(--FULL_ROW);
--r2: var(--FULL_ROW);
--r1: var(--FULL_ROW); /* 12291; 0b 11 00 00 00 00 00 11 */
--r0: var(--FULL_ROW); /* 7; 0b 00 00 00 00 00 01 11 (reversed in game) */
--r7-out: var(--r7);
--r6-out: var(--r6);
--r5-out: var(--r5);
--r4-out: var(--r4);
--r3-out: var(--r3);
--r2-out: var(--r2);
--r1-out: var(--r1);
--r0-out: var(--r0);
--MAX_X: 55;
--MAX_Y: 95;
--INIT_BIT_X: 27.5;
--INIT_BIT_Y: 45.5;
--INIT_SPEED: 1.5;
--INIT_DIR: -45deg;
--MAX_DELTA_Y: 1.9;
--MAX_DELTA_X: 3.9;
--MAX_SPEED: 6;
/* different max deltas per axis effectively alters DIR just by increasing speed... */
--bit-x-in: var(--INIT_BIT_X); /* 0 to 55 */
--bit-x-out: var(--bit-x-in);
--bit-y-in: var(--INIT_BIT_Y); /* 0 to 95 */
--bit-y-out: var(--bit-y-in);
--bit-speed-in: var(--INIT_SPEED);
--bit-speed-out: var(--bit-speed-in);
--bit-dir-in: var(--INIT_DIR);
--bit-dir-out: var(--bit-dir-in);
--INIT_GUIDE_X: 26; /* range is -1 to 53 (same global grid +- 1) */
--INIT_GUIDE_Y: 89; /* always (could play with that though) at 89 and 90 (height is 2) */
--guide-x-in: var(--INIT_GUIDE_X);
--guide-y-in: var(--INIT_GUIDE_Y);
--guide-x-out: var(--guide-x-in);
--guide-y-out: var(--guide-y-in);
--prev-guidexin-in: var(--guide-x-in);
--prev-guidexin-out: var(--prev-guidexin-in);
}
.guide .phase-capture > * { position: absolute; top: 0px; bottom: 0px; opacity: 0; }
.guide .phase-capture :nth-child(1) {
left: 0px;
width: calc(50vw - (var(--cols) / 2 + 1 - var(--guide-x-in)) * var(--col-w));
background: rgba(255, 0, 0, 0.5);
}
.guide .phase-capture :nth-child(2) {
left: calc(50vw - (var(--cols) / 2 + 1 - var(--guide-x-in)) * var(--col-w));
width: calc(2 * var(--col-w));
background: rgba(0, 255, 0, 0.5);
}
.guide .phase-capture :nth-child(3) {
left: calc(50vw - (var(--cols) / 2 - 3 - var(--guide-x-in)) * var(--col-w));
width: calc(2 * var(--col-w));
background: rgba(0, 255, 0, 0.5);
}
.guide .phase-capture :nth-child(4) {
left: calc(50vw - (var(--cols) / 2 - 5 - var(--guide-x-in)) * var(--col-w));
width: calc(100vw - (50vw - (var(--cols) / 2 - 5 - var(--guide-x-in)) * var(--col-w)));
background: rgba(255, 0, 250, 0.5);
}
.game:has(.guide .phase-capture :nth-child(1):hover) {
--guide-x-out: max(-1, var(--guide-x-in) - 4);
}
.game:has(.guide .phase-capture :nth-child(2):hover) {
--guide-x-out: max(-1, var(--guide-x-in) - 1);
}
.game:has(.guide .phase-capture :nth-child(3):hover) {
--guide-x-out: min(53, var(--guide-x-in) + 1);
}
.game:has(.guide .phase-capture :nth-child(4):hover) {
--guide-x-out: min(53, var(--guide-x-in) + 4);
}
.game:has(#constrain-toggle:not(:checked)) {
--constrain: 0;
}
.game:has(#paper-bricks:checked) {
--rip-through-mode: 1;
}
.game:has(#infinite-lives:checked) {
--infinite-lives: 1;
}
.game:has(#zero-deaths:checked) {
--zero-deaths: 1;
}
.game:has(.breakout .phase-1:hover) {
/*
// delta = sin(var(--bit-dir-in) + 90deg) * var(--bit-speed-in)
// sign = ((raw delta gte 0) - 0.5) * 2 // either -1 or 1
// abs_delta = max(delta, -1 * delta)
// pick_delta = min(MAX_DELTA_-, abs_delta)
// use delta = sign * pick_delta
*/
--bit-x-raw-delta: calc(sin(var(--bit-dir-in) + 90deg) * var(--bit-speed-in));
--bit-x-delta-sign: calc(1 + max(-1, min(0, 100000 * var(--bit-x-raw-delta))) * 2);
--bit-x-use-delta: calc(
var(--bit-x-delta-sign) * min(
var(--MAX_DELTA_X),
max(var(--bit-x-raw-delta), -1 * var(--bit-x-raw-delta))
)
);
--bit-x-next: calc(var(--bit-x-in) + var(--bit-x-use-delta));
--bit-x-clamped: clamp(0, var(--bit-x-next), var(--MAX_X));
--bit-y-raw-delta: calc(cos(var(--bit-dir-in) + 90deg) * var(--bit-speed-in));
--bit-y-delta-sign: calc(1 + max(-1, min(0, 100000 * var(--bit-y-raw-delta))) * 2);
--bit-y-use-delta: calc(
var(--bit-y-delta-sign) * min(
var(--MAX_DELTA_Y),
max(var(--bit-y-raw-delta), -1 * var(--bit-y-raw-delta))
)
);
--bit-y-next: calc(var(--bit-y-in) + var(--bit-y-use-delta));
--bit-y-clamped: clamp(0, var(--bit-y-next), var(--MAX_Y));
/* brick collisions:
can only collide once after hitting the roof or hitting the guide paddle thing
after collision, it can pass through bricks
collision always mirrors dir over the X axis (? not quite ... though I can't tell)
if Y-out - bit-height / 2 is in a row, break if:
X-out + bit-width / 2 is inside a brick
else keep moving
bricks top = calc(var(--row-h) * 8 * 2)
bricks height = calc(var(--row-h) * 8 * 2)
--bit-on-brick-wall = centerY > topOfBricks && centerY < bottomOfBricks
*/
--bit-y-center: calc(var(--bit-y-clamped) + 0.5);
--bit-x-center: calc(var(--bit-x-clamped) + 0.5);
--brick-wall-t-and-h: 16; /* 8 * 2, don't need or want <length>s here */
--bit-y-rel-to-brick-top: calc(var(--bit-y-center) - var(--brick-wall-t-and-h));
--bit-on-brick-wall: calc(
(-1 * max(-1, min(0, -100000 * (
var(--bit-y-rel-to-brick-top)
)))) *
(-1 * max(-1, min(0, 100000 * (
var(--bit-y-center) - (var(--brick-wall-t-and-h) * 2)
))))
);
--INTdex: calc(var(--bit-y-rel-to-brick-top) / var(--brick-wall-t-and-h) * 8 - 0.5);
--row-val: calc(
var(--can-break-in) *
var(--bit-on-brick-wall) * (
(1 + max(-1, 10000 * min(var(--INTdex) - 0, 0 - var(--INTdex)))) * var(--r7) +
(1 + max(-1, 10000 * min(var(--INTdex) - 1, 1 - var(--INTdex)))) * var(--r6) +
(1 + max(-1, 10000 * min(var(--INTdex) - 2, 2 - var(--INTdex)))) * var(--r5) +
(1 + max(-1, 10000 * min(var(--INTdex) - 3, 3 - var(--INTdex)))) * var(--r4) +
(1 + max(-1, 10000 * min(var(--INTdex) - 4, 4 - var(--INTdex)))) * var(--r3) +
(1 + max(-1, 10000 * min(var(--INTdex) - 5, 5 - var(--INTdex)))) * var(--r2) +
(1 + max(-1, 10000 * min(var(--INTdex) - 6, 6 - var(--INTdex)))) * var(--r1) +
(1 + max(-1, 10000 * min(var(--INTdex) - 7, 7 - var(--INTdex)))) * var(--r0)
)
);
--INTdex2: calc(var(--bit-x-center) / (var(--MAX_X) + 1) * 14 - 0.5);
--bin-e-trunc: var(--row-val);
--brick-collision: calc(
(1 + max(-1, 10000 * min(var(--INTdex2) - 0, 0 - var(--INTdex2)))) * var(--bin-e-1) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 1, 1 - var(--INTdex2)))) * var(--bin-e-2) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 2, 2 - var(--INTdex2)))) * var(--bin-e-3) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 3, 3 - var(--INTdex2)))) * var(--bin-e-4) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 4, 4 - var(--INTdex2)))) * var(--bin-e-5) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 5, 5 - var(--INTdex2)))) * var(--bin-e-6) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 6, 6 - var(--INTdex2)))) * var(--bin-e-7) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 7, 7 - var(--INTdex2)))) * var(--bin-e-8) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 8, 8 - var(--INTdex2)))) * var(--bin-e-9) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 9, 9 - var(--INTdex2)))) * var(--bin-e-10) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 10, 10 - var(--INTdex2)))) * var(--bin-e-11) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 11, 11 - var(--INTdex2)))) * var(--bin-e-12) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 12, 12 - var(--INTdex2)))) * var(--bin-e-13) +
(1 + max(-1, 10000 * min(var(--INTdex2) - 13, 13 - var(--INTdex2)))) * var(--bin-e-14)
);
--bin-f-trunc: var(--brick-collision);
--bin-f-shift: var(--INTdex2);
--bin-b-trunc: var(--bin-f-LEFT);
--bin-be-op: var(--bin-XOR);
/* now --bin-be-VAL =
( --brick-collision[0|1] shifted-left --INTdex2[0,13] ) XOR --row-val[bin-e-VAL]
*/
--r7-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 0, 0 - var(--INTdex))))
);
--r7-out: calc(
var(--r7-needs-update) * var(--bin-be-VAL) +
(1 - var(--r7-needs-update)) * var(--r7)
);
--r6-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 1, 1 - var(--INTdex))))
);
--r6-out: calc(
var(--r6-needs-update) * var(--bin-be-VAL) +
(1 - var(--r6-needs-update)) * var(--r6)
);
--r5-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 2, 2 - var(--INTdex))))
);
--r5-out: calc(
var(--r5-needs-update) * var(--bin-be-VAL) +
(1 - var(--r5-needs-update)) * var(--r5)
);
--r4-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 3, 3 - var(--INTdex))))
);
--r4-out: calc(
var(--r4-needs-update) * var(--bin-be-VAL) +
(1 - var(--r4-needs-update)) * var(--r4)
);
--r3-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 4, 4 - var(--INTdex))))
);
--r3-out: calc(
var(--r3-needs-update) * var(--bin-be-VAL) +
(1 - var(--r3-needs-update)) * var(--r3)
);
--r2-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 5, 5 - var(--INTdex))))
);
--r2-out: calc(
var(--r2-needs-update) * var(--bin-be-VAL) +
(1 - var(--r2-needs-update)) * var(--r2)
);
--r1-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 6, 6 - var(--INTdex))))
);
--r1-out: calc(
var(--r1-needs-update) * var(--bin-be-VAL) +
(1 - var(--r1-needs-update)) * var(--r1)
);
--r0-needs-update: calc(var(--brick-collision) *
(1 + max(-1, 10000 * min(var(--INTdex) - 7, 7 - var(--INTdex))))
);
--r0-out: calc(
var(--r0-needs-update) * var(--bin-be-VAL) +
(1 - var(--r0-needs-update)) * var(--r0)
);
/* if you brokethrough; transition this value from 1 up to 100 then stay there */
--has-broke-through: calc(-1 * max(-1, min(0, 1000 * (
var(--r7-out) - var(--FULL_ROW)
))));
--brokethrough-out: calc(
var(--has-broke-through) *
min(100, var(--brokethrough-in) + 1)
);
--broke-at-out: calc(
/* previously did not break through && has broke through now, set to current */
(1 - min(1, var(--brokethrough-in))) *
var(--has-broke-through) *
(var(--INTdex2) * 4 + 2) +
/* else set = previously DID break through already && previous index */
min(1, var(--brokethrough-in)) * var(--broke-at-in)
);
/* pretend guide is 2 wider (1 overflow each side) so it doesn't seem to pass through corners */
--bit-guide-collision: calc(
var(--can-guide-in) *
(1 + max(-1, min(0, 100000 * (var(--bit-x-center) - (var(--guide-x-out) - 1))))) *
(1 + max(-1, min(0, -100000 * (var(--bit-x-center) - (var(--guide-x-out) + 5))))) *
(1 + max(-1, min(0, 100000 * (var(--bit-y-center) - var(--guide-y-out))))) *
(1 + max(-1, min(0, -100000 * (var(--bit-y-center) - (var(--guide-y-out) + 3)))))
);
/* -1 to 1 <number> dir scale */
--bit-guide-x-collision-dir: calc(
var(--bit-guide-collision) * (
((var(--bit-x-center) - var(--guide-x-out)) / 6 - 0.5) * 2
)
);
/* --bit-moving-x-dir: clamp(-1, 1000 * (var(--bit-x-next) - var(--bit-x-in)), 1); */
/* 0 friction reflection */
--bit-x-out: calc(
var(--bit-x-clamped) -
(var(--bit-x-next) - var(--bit-x-clamped))
);
--top-to-bottom: calc(
-1 * max(-1, min(0, 100000 * (var(--bit-y-in) - var(--bit-y-next))))
);
/* if brick-collision, clamp Y to the brick so it reflects */
--bit-y-clamped-collision: calc(
var(--brick-collision) * (
var(--top-to-bottom) * clamp(
0,
var(--bit-y-next),
var(--brick-wall-t-and-h) - 0.5 + var(--INTdex) * 2
) +
(1 - var(--top-to-bottom)) * clamp(
var(--brick-wall-t-and-h) - 0.5 + (var(--INTdex) + 1) * 2,
var(--bit-y-next),
var(--MAX_Y)
)
) +
(1 - var(--brick-collision)) * var(--bit-y-clamped)
);
--use-y-clamp: calc(
var(--rip-through-mode) * var(--bit-y-clamped) +
(1 - var(--rip-through-mode)) * var(--bit-y-clamped-collision)
);
/* 0 friction reflection */
--bit-y-out: calc(
var(--use-y-clamp) -
(var(--bit-y-next) - var(--use-y-clamp))
);
--bit-x-wall-collided: calc(-1 * max(-1, 100000 * min(
var(--bit-x-next) - var(--bit-x-clamped),
var(--bit-x-clamped) - var(--bit-x-next)
)));
--y-collision: calc(-1 * max(-1, 100000 * min(
var(--bit-y-next) - var(--use-y-clamp),
var(--use-y-clamp) - var(--bit-y-next)
)));
--both-collision: calc(
var(--bit-x-wall-collided) * var(--y-collision)
);
--no-collision: calc(
1 - min(1, var(--bit-x-wall-collided) + var(--y-collision))
);
--only-x-collision: calc((1 - var(--both-collision)) * var(--bit-x-wall-collided));
--only-y-collision: calc((1 - var(--both-collision)) * var(--y-collision));
--bit-dir-next: calc(
var(--only-x-collision) * (180deg - var(--bit-dir-in)) +
var(--only-y-collision) * var(--bit-dir-in) * -1 +
var(--both-collision) * (180deg - var(--bit-dir-in)) * -1 +
var(--no-collision) * var(--bit-dir-in)
);
/* -1 to -0.25 -> 140deg to 100deg, 0.25 to 1 -> 80deg to 40deg, else reflect */
--bit-dir-out: calc(
var(--bit-guide-collision) * (
clamp(0, (var(--bit-guide-x-collision-dir) - 0.25) * 10000, 1) * (
80deg - (40deg * (var(--bit-guide-x-collision-dir) - 0.25) * 4 / 3)
) +
clamp(-1, (var(--bit-guide-x-collision-dir) + 0.25) * 10000, 0) * -1 * (
100deg - (40deg * (var(--bit-guide-x-collision-dir) + 0.25) * 4 / 3)
) + (
(1 - clamp(0, (var(--bit-guide-x-collision-dir) - 0.25) * 10000, 1)) *
(1 - clamp(-1, (var(--bit-guide-x-collision-dir) + 0.25) * 10000, 0) * -1) * (
var(--bit-dir-in) * -1
)
)
) +
(1 - var(--bit-guide-collision)) * var(--bit-dir-next)
);
/*
// if !on the wall, can-break-out = true
// else (is on the wall) (
// if there was a BRICK collision, can-break-out = rip-through-mode
// else (no BRICK collision), can-break-out = can-break-in
// )
*/
--can-break-out: calc(
(1 - var(--bit-on-brick-wall)) +
var(--bit-on-brick-wall) * (
var(--brick-collision) * var(--rip-through-mode) +
(1 - var(--brick-collision)) * var(--can-break-in)
)
);
--bit-above-guide: calc(-1 * max(-1, min(0, 100000 * (var(--bit-y-out) - var(--guide-y-out)))));
--can-guide-out: calc(
var(--bit-above-guide) +
(1 - var(--bit-above-guide)) * (
(1 - var(--bit-guide-collision)) * var(--can-guide-in)
)
);
--prev-guidexin-out: var(--guide-x-in);
/* (-8 to 8) + (-4 to 4) if moving the same direction, last frame counts double */
--current-guide-speed: calc(
(var(--guide-x-out) - var(--prev-guidexin-in)) +
(var(--guide-x-out) - var(--guide-x-in))
);
--cgs-abs-scale: calc(
max(
var(--current-guide-speed),
-1 * var(--current-guide-speed)
) / 12
);
--bit-guide-hit-in-middle: calc(1 - clamp(0, 10000 * (
max(var(--bit-guide-x-collision-dir), -1 * var(--bit-guide-x-collision-dir)) - 1 / 2
), 1));
--bit-hit-slow-guide-mid: calc(
var(--bit-guide-hit-in-middle) * (
1 + max(-1, min(0, -100000 * (var(--cgs-abs-scale) - 0.17)))
)
);
/*
// if hit (else 0) and (^^^ hit in middle of the guide AND guide speed was slow (0.17 or less)),
// then bit-speed-delta is negative by 1/4 initial speed, else positive scaled by guide speed
// max-speed-change = var(--INIT_SPEED) / 2
*/
--bit-speed-delta: calc(
var(--bit-guide-collision) * (
-1 * var(--bit-hit-slow-guide-mid) * var(--INIT_SPEED) / 8 +
(1 - var(--bit-hit-slow-guide-mid)) * var(--cgs-abs-scale) * var(--INIT_SPEED) / 2
)
);
/* minimum speed increases with number of points up to a max of +1 at the start of level 3 */
--bit-speed-out: clamp(
var(--INIT_SPEED) + min(2, var(--points-total-in) / 448) / 2, (
var(--bit-speed-in) + var(--bit-speed-delta)
), var(--MAX_SPEED)
);
--test-out: calc(var(--bit-speed-out) * 100000);
/*
// todo: register --current-guide-speed var
// if headon, slow down
// if guide still, don't change
// if same dir, speed up
// var(--guide-current-dir) // -1, 0, or 1
// var(--bit-guide-x-collision-dir) // [-1.0 to 1.0] dir scalar
*/
/* extra life every level, max lives 6 */
--bit-needs-our-help: calc(
(1 - var(--zero-deaths)) *
(1 + max(-1, min(0, 100000 * (
var(--bit-y-next) - var(--MAX_Y)
))))
);
--lives-out: min(6,
var(--lives-in) +
var(--level-changed) -
var(--bit-needs-our-help) * (1 - var(--infinite-lives))
);
--row-points-INTdex: calc(var(--INTdex, 0) / 2 - 0.5);
--points-total-out: calc(
var(--points-total-in) +
var(--brick-collision) * ((3 - var(--row-points-INTdex)) * 2 + 1)
);
--bin-c-trunc: (var(--points-total-out) / 45);
--bin-c-mod: 10; /* every 45 pts, goto next palette of 10. 448 pts is max/lvl */
--palette-out: var(--bin-c-MOD, 0);
--palette-changed: calc(-1 * max(-1, 100000 * min(
var(--palette-in) - var(--palette-out),
var(--palette-out) - var(--palette-in)
)));
--bin-d-trunc: var(--points-total-out);
--bin-d-mod: 448; /* every 448pts is max per lvl */
--level-out: calc(
(var(--bin-d-trunc) - var(--bin-d-MOD, 0)) / var(--bin-d-mod)
);
--level-changed: calc(-1 * max(-1, 100000 * min(
var(--level-in) - var(--level-out),
var(--level-out) - var(--level-in)
)));
/* todo: at level=5 (2240pts) --seq-out is procucing an unaccounted for SEQ */
/* because level changes from 4 to 5 AND palette changes from 9 to 0 */
/* original Woz game only had 2 levels soooooooooooo mayyybe... */
/* we'll say that ^ SEQ = Win / Game Complete (after 5 levels (0,1,2,3,4))?! */
/* TODO: ^ Yes, great idea. */
--seq-out: calc(
var(--palette-changed) * var(--SET_PALETTE) +
var(--level-changed) * var(--NEXT_LEVEL_PROMPT) +
var(--bit-needs-our-help) * (
min(1, var(--lives-out)) * var(--RESPAWN) +
(1 - min(1, var(--lives-out))) * var(--GAME_OVER)
)
);
}
.game:has(.menu-pallete:hover) {
--c1-out: #7c567e;
--c2-out: #7300E6;
--c3-out: #FB04C2;
}
.game:has(.start-game:hover) {
--seq-out: var(--NEXT_LEVEL);
--frame-out: 0;
--points-total-out: 0;
--lives-out: 3;
--level-in: 0;
--level-out: 0;
/*
START_GAME
RESPAWN
SET_PALETTE
NEXT_LEVEL_PROMPT
NEXT_LEVEL
GAME_COMPLETE
GAME_OVER
*/
}
.game:has(.start-game:hover button:focus) {
--cheats-active-out: 0;
}
.game:has(.respawn:hover) {
--seq-out: var(--SET_PALETTE);
}
.game:has(.clock .phase-capture:hover) {
--frame-out: calc(var(--frame-in) + 1);
}
.game:has(.set-palette:hover) {
--seq-out: var(--CLOCK);
}
.game:has(.next-level-prompt:hover) {
--seq-out: var(--NEXT_LEVEL);
}
.game:has(.game-complete-sequence:hover button:focus),
.game:has(.game-over-sequence:hover button:focus),
.game:has(.respawn:hover button:focus),
.game:has(.next-level-sequence:hover) {
--bit-x-out: var(--INIT_BIT_X);
--bit-y-out: var(--INIT_BIT_Y);
--bit-speed-out: var(--INIT_SPEED);
--bit-dir-out: var(--INIT_DIR);
--guide-x-out: var(--INIT_GUIDE_X);
--guide-y-out: var(--INIT_GUIDE_Y);
}
.game:has(.game-complete-sequence:hover button:focus),
.game:has(.game-over-sequence:hover button:focus),
.game:has(.next-level-prompt:hover .quit-button:focus),
.game:has(.respawn:hover .quit-button:focus),
.game:has(.next-level-sequence:hover) {
--seq-out: var(--SET_PALETTE); /* TODO: fancy rebuild rows sequence? */
--r7-out: var(--FULL_ROW);
--r6-out: var(--FULL_ROW);
--r5-out: var(--FULL_ROW);
--r4-out: var(--FULL_ROW);
--r3-out: var(--FULL_ROW);
--r2-out: var(--FULL_ROW);
--r1-out: var(--FULL_ROW);
--r0-out: var(--FULL_ROW);
--brokethrough-out: 0;
--broke-at-out: 0;
}
.game:has(.game-complete-sequence:hover button:focus:not(:active)),
.game:has(.game-over-sequence:hover button:focus),
.game:has(.next-level-prompt:hover .quit-button:focus),
.game:has(.respawn:hover .quit-button:focus) {
--seq-out: var(--START_GAME);
--lives-out: 3;
--points-total-out: 0;
}
.game:has(.debug-info-toggle:checked)::after {
counter-reset: framex var(--frame-out, 0)
palette var(--palette-out, 0)
levelx var(--level-out, 0)
bao var(--broke-at-out, 0)
pto var(--points-total-out, 0)
test var(--test-out, 0);
content: counter(framex) " "
counter(palette) " "
counter(levelx) " "
counter(bao) " "
counter(pto) "\A"
counter(test);
position: absolute;
top: 0;
right: 100px;
white-space: pre;
text-align: right;
}
.palette {
--c1-in: black;
--c2-in: black;
--c3-in: black;
--c1-out: var(--c1-in);
--c2-out: var(--c2-in);
--c3-out: var(--c3-in);
}
.palette:has(.set-palette .phase-capture :nth-child(1):hover) {
--c1-out: #8DB3F9;
--c2-out: #3EBEFF;
--c3-out: #0057F6;
}
.palette:has(.set-palette .phase-capture :nth-child(2):hover) {
--c1-out: #AEE0AD;
--c2-out: #81D012;
--c3-out: #05A801;
}
.palette:has(.set-palette .phase-capture :nth-child(3):hover) {
--c1-out: #F9C3FA;
--c2-out: #F878F7;
--c3-out: #DB00CD;
}
.palette:has(.set-palette .phase-capture :nth-child(4):hover) {
--c1-out: #ADC8FA;
--c2-out: #5BDB56;
--c3-out: #0158F8;
}
.palette:has(.set-palette .phase-capture :nth-child(5):hover) {
--c1-out: #F4A7C5;
--c2-out: #57F898;
--c3-out: #E7005B;
}
.palette:has(.set-palette .phase-capture :nth-child(6):hover) {
--c1-out: #c0edd2;
--c2-out: #6B88FF;
--c3-out: #3fd37a;
}
.palette:has(.set-palette .phase-capture :nth-child(7):hover) {
--c1-out: #FABEAD;
--c2-out: #7F7F7F;
--c3-out: #F73700;
}
.palette:has(.set-palette .phase-capture :nth-child(8):hover) {
--c1-out: #CEC3FC;
--c2-out: #AB0023;
--c3-out: #6B47FF;
}
.palette:has(.set-palette .phase-capture :nth-child(9):hover) {
--c1-out: #8BB2FA;
--c2-out: #F73700;
--c3-out: #0158F8;
}
.palette:has(.set-palette .phase-capture :nth-child(10):hover) {
--c1-out: #FABAA7;
--c2-out: #FFA347;
--c3-out: #F73700;
}
.set-palette .phase-capture :nth-child(1) { --palette: 0; }
.set-palette .phase-capture :nth-child(2) { --palette: 1; }
.set-palette .phase-capture :nth-child(3) { --palette: 2; }
.set-palette .phase-capture :nth-child(4) { --palette: 3; }
.set-palette .phase-capture :nth-child(5) { --palette: 4; }
.set-palette .phase-capture :nth-child(6) { --palette: 5; }
.set-palette .phase-capture :nth-child(7) { --palette: 6; }
.set-palette .phase-capture :nth-child(8) { --palette: 7; }
.set-palette .phase-capture :nth-child(9) { --palette: 8; }
.set-palette .phase-capture :nth-child(10) { --palette: 9; }
.set-palette .phase-capture > * {
position: absolute;
inset: 0;
--palette-matches: calc(1 + max(-1, 100000 * min(
var(--palette) - var(--palette-out, 0),
var(--palette-out, 0) - var(--palette)
)));
left: calc(100% - var(--palette-matches) * 100%);
}
.game-over-sequence .msg-1 {
--msg: "Beautiful little bit... This journey is long.\A\A"
"Know this; The Player Within is The Player Above.\A"
"Belief in yourself is guidance from them.\A\A"
"You can do this. All five still to go...";
}
.game-over-sequence .msg-2 {
--msg: "Wonderful little bit! This journey is long.\A\A"
"Know this; The Player Within is The Player Above.\A"
"Belief in yourself is guidance from them.\A\A"
"You can do this. One down, four to go...";
}
.game-over-sequence .msg-3 {
--msg: "Amazing little bit! This journey is long.\A\A"
"Know this; The Player Within is The Player Above.\A"
"Belief in yourself is guidance from them!\A\A"
"Roughly half way! Two down, three to go...";
}
.game-over-sequence .msg-4 {
--msg: "Incredible little bit!\A\A"
"Know this; The Player Within is The Player Above.\A"
"Belief in yourself is guidance from them!\A\A"
"HOME STRETCH! Three down, just two to go!";
}
.game-over-sequence .msg-5 {
--msg: "Little bit, you are truly a marvel!\A\A"
"The Player Above is surely proud!\A"
"Belief in yourself is guidance from them!\A\A"
"Four have gone, the last was this!";
}
.game-complete-menu,
.game-over-menu {
overflow: hidden;
}
.game-over-sequence .msg-1 { --over: 0; }
.game-over-sequence .msg-2 { --over: 1; }
.game-over-sequence .msg-3 { --over: 2; }
.game-over-sequence .msg-4 { --over: 3; }
.game-over-sequence .msg-5 { --over: 4; }
.game-over-sequence .msg {
position: absolute;
padding-top: calc(var(--row-h) * 2);
inset: 0;
--over-matches: calc(1 + max(-1, 100000 * min(
var(--over) - var(--level-out, 0),
var(--level-out, 0) - var(--over)
)));
left: calc(100% - var(--over-matches) * 100%);
}
.game-complete-sequence .msg::before,
.game-over-sequence .msg::before {
content: var(--msg);
white-space: pre-wrap;
}
.game-complete-sequence .msg-1 {
--msg: "Little Bit! What an adventure you've had!\A\A"
"We were hooked from the moment you spawned.\A"
"Following your excitement through the top\A"
"again and again!\A\A"
"The Player Above, as thrilled as you!";
}
.game-complete-sequence .msg-2 {
--msg: "Little Bit! What an adventure you've had!!\A\A"
"We were hooked from the moment you spawned.\A"
"Following your excitement through the top\A"
"again and again!\A\A"
"~ Would you like another show? ~";
}
.game-complete-sequence .msg-3 {
--msg: "Little Bit! What an adventure you've had!!!\A"
"Through the top again and again!\A\A"
"The Player Within is The Player Above;\A"
"Belief in yourself is guidance from them!\A\A"
"~ You are a treasure of the universe. ~";
}
.game-complete-sequence .msg-4 {
--msg: "Little bit! You are as incredible\A"
"as the adventure you've had!\A\A"
"Surely you feel it now!\A"
"The Player Within is The Player Above!\A\A"
"~ Your guidance has made all the difference. ~";
}
.game-complete-sequence .msg-5 {
--msg: "Little bit! The universe is in love;\A"
"your adventure, as joyous as you!\A\A"
"A nearly unshaken belief in yourself is remarkable!\A\A"
"~ Your guidance has uplifted us all. ~";
}
.game-complete-sequence .msg-6 {
--msg: "Little bit! The entire multiverse in awe.\A"
"Your unshaken belief in yourself is the unresisted\A"
"love of existence itself. A true reflection of\A"
"The Player Above. You are magnificent.\A\A"
"...You can have any life you imagine,\A"
"what sort of life will you choose?";
}
.game-complete-sequence .msg-7 {
--msg: "Little Bit! What fun you've had!\A\A"
"A cheat or two, for the win, through the top,\A"
"again and again!\A\A"
"The Player Within is The Player Above!\A\A"
"~ Your guidance has brought joy to your little bit! ~";
}
.game-complete-sequence .msg-1 { --ending: 1; }
.game-complete-sequence .msg-2 { --ending: 2; }
.game-complete-sequence .msg-3 { --ending: 3; }
.game-complete-sequence .msg-4 { --ending: 4; }
.game-complete-sequence .msg-5 { --ending: 5; }
.game-complete-sequence .msg-6 { --ending: 6; }
.game-complete-sequence .msg-7 { --ending: 7; }
.game-complete-sequence .msg {
position: absolute;
padding-top: calc(var(--row-h) * 2);
--match-value: calc(
var(--cheats-active-out) * 7 +
(1 - var(--cheats-active-out)) * var(--lives-out, 0)
);
inset: 0;
--ending-matches: calc((1 + max(-1, 100000 * min(
var(--ending) - var(--match-value),
var(--match-value) - var(--ending)
)))
);
left: calc(100% - var(--ending-matches) * 100%);
}
.control {
position: absolute;
inset: 0px;
display: grid;
}
.info-panel {
z-index: 6;
position: absolute;
top: 50%;
left: 50%;
transform: translate(
-50%,
calc(var(--max-h) * 1px / -2)
);
width: calc(var(--max-w) * 1px);
bottom: auto;
height: calc(var(--row-h) * 4 * 5);
isolation: isolate;
}
.info-panel:has(.info-toggle :checked)::before {
content: "";
z-index: -1;
position: absolute;
width: 100vw;
height: 100vh;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.info-toggle input { display: none; }
.info-panel:has(.info-toggle :checked) {
height: calc(var(--max-h) * 1px);
}
.btn {
border: calc(var(--row-h) * 0.2) solid currentColor;
border-radius: calc(var(--row-h) * 0.25);
padding: 0.5em;
font-size: calc(var(--row-h) * 1.75);
color: var(--c3-out);
cursor: pointer;
position: relative;
overflow: hidden;
background: none;
}
.btn.btn2 { color: var(--c2-out); }
.btn:focus::after,
.btn:hover::after {
content: "";
background: var(--c2-out);
position: absolute;
inset: 0;
opacity: 0.125;
}
.btn:active::after {
opacity: 0.25;
}
.info-toggle:has(input:not(:checked)) {
position: absolute;
inset: 0;
font-size: 0px;
z-index: 3;
cursor: pointer;
border: none;
background: none;
}
.info-toggle:has(input:not(:checked))::after {
content: none;
}
.info-toggle:has(input:checked) {
position: absolute;
left: 50%;
bottom: calc(var(--row-h) * 17);
padding: calc(var(--row-h) * 1.5);
transform-origin: 0px 50%;
transform: translateX(calc(var(--row-h) * 11 * var(--scaleX))) scaleX(var(--scaleX));
z-index: 6;
}
.info-panel .menu {
position: absolute;
}
.info-shield-badge {
display: block;
position: relative;
top: calc(var(--row-h) * -0.5);
}
.info-shield-badge img {
height: calc(var(--row-h) * 3);
}
.info-cheats {
overflow: hidden;
height: calc(
var(--cheats-active-out) * (
var(--row-h) * 8
)
);
}
.info-links {
position: absolute;
bottom: calc(var(--row-h) * 1);
left: calc(var(--row-h) * 2);
}
.blog-link {
display: block;