-
Notifications
You must be signed in to change notification settings - Fork 1
/
chikischefs.p8
2186 lines (1842 loc) · 86.4 KB
/
chikischefs.p8
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
pico-8 cartridge // http://www.pico-8.com
version 34
__lua__
-- chikis chefs
-- by 7th beat games
-- a fangame of chiki's chase by david fu
-- notes: tick here is mostly used to mean the length of 1 note in the tracker
-- not the way pico uses ticks, which is "every note in the tracker takes [sfx pattern speed] ticks" e.g. 16 ticks per note
-- 1 pico tick = 183/22050 s
-- dsets
-- 0 = high score
-- 1 = last score (pass to ending.p8)
-- 2 = last level reached
-- 3 = difficulty.name
-- 11-20 = fruit array (as id numbers)
testbug1 = false
testbug1_round = 30
testbug1_level = 1
godmode = false
-- testbug1: if
-- 1) we are on the last set of side b
-- 2) the basket's first fruit is *not* chirimoya/watermelon
-- 3) the next basket's first fruit is chirimoya/watermelon
-- then it will fail the last fruit of the basket early. why?????
-- solved now
fizzd_path = false -- alt path for multicart to work locally
testwin = false
mstate =
{
intro = "intro",
call = "call",
response = "response"
}
--[[gameresult =
{
playing = 0,
gameover = 1,
won = 2,
fullwon = 3
}]]--
mside =
{
a = "a",
b = "b"
}
game_difficulties =
{
very_easy = {
name = "very easy",
speed = 20
},
easy = {
name = "easy",
speed = 18
},
normal = {
name = "normal",
speed = 16
},
hard = {
name = "hard",
speed = 14
},
very_hard = {
name = "very hard",
speed = 12
},
very_hard_plus = {
name = "very hard+",
speed = 10
}
}
game_difficulty_ids =
{
game_difficulties.very_easy,
game_difficulties.easy,
game_difficulties.normal,
game_difficulties.hard,
game_difficulties.very_hard,
game_difficulties.very_hard_plus
}
current_speed = 16
default_speed = 16
current_difficulty = game_difficulties.normal
current_difficulty_id = 3
difficulty_selection = false
cartdata("chikischefs")
--outside to save between runs
input_offset = 90 -- in ms
input_offset_default = 90
function _init()
poke(0x5f00+92,255) --disable repeat button press
z = 0
currfruits = {}
bubblefruits = {}
slices = {}
tscratch = -1
tcatanim = -1
last=0
-- conductor
tick = 0 -- is stat(50) but always increasing
tickl = 0 -- is stat(50)
tickf = 0 -- is tick but interpolated
game_tick_speed = 16 --set in music tab. 16 means 16'ticks' per note.
game_tick_ui = 0 --
single_tick_length = 183/22050 --1 single tick (in pico terms) is 183 samples at 22050hz
hit_margin = 0.8 -- in ticks! plus minus. see change_difficulty() for hardcoded
statloops = -1
statprev =0
statcap = 16 --stat per pattern
spb = 16 -- stat per beat
bar = 0
calltime = false
responsetime = false
notesstr = ""
bbeats = ""
newtick = false
tick_response = 0
sylaudio = 0
anybtn = false
closestfruit = 1
bubbles_xoffset = 8
rabbit_state = 0
headbob = false
perfect_round = false
perfect_rounds_count = 0
playing = false
difficulty_selection = false -- if playing = false, then two menus, depending on this var
trabbitappear = 0
gameover = false
won = false
allwon = false
tgameover = 0
music_state = mstate.intro
current_level = 0 -- increase every 4 rounds
current_level_show = 0
prev_level = 0
round = testbug1 and testbug_round or 0 --rounds increase every call phase
arr_basket = {}
arr_basket_datum = {} --the motif of the round, set every 4 baskets
arr_basket_show = {} -- arr_basket but updated at start of next bar only
arr_basket_beats = {} -- linear list of beat numbers, {0,1,4..15}
arr_basket_beats_show = {} --refresh on bar
arr_basket_beats_results = {} -- results for each hit
-- false when used
flag_refreshed_response = true
flag_refreshed_call = true
flag_refreshed_newbar = true
lives = maxlives
currentfruits = {fruits.grape} --starting fruits
currentfruits_show = {fruits.grape} --same but updated on bar
slices = {}
--load input offset from save data if available
_input_offset = dget(60)
if (_input_offset ~= 0) then
input_offset = _input_offset
end
str_last_margin = ""
end
function reset()
end
function change_difficulty(_increase)
if _increase then
current_difficulty_id+= 1
else
current_difficulty_id-= 1
end
if current_difficulty_id > #game_difficulty_ids then current_difficulty_id = 1 end
if current_difficulty_id == 0 then current_difficulty_id = #game_difficulty_ids end
printh ("huh ".. current_difficulty_id)
current_difficulty = game_difficulty_ids[current_difficulty_id]
current_speed = current_difficulty.speed
if current_difficulty_id < 3 then
hit_margin = 1
else
hit_margin = 0.85
end
end
function _update60()
if playing then
play_update()
else
headbob = time() * 7.5 % 4 < 1
if difficulty_selection == false then
--start screen + offset
if btnp(5) then difficulty_selection = true end
if btnp(0) then input_offset -= 5
dset(60,input_offset)
end
if btnp(1) then
input_offset += 5
dset(60,input_offset)
end
if btnp(3) then
input_offset = input_offset_default
dset(60,input_offset)
end
else
-- difficulty select screen
if btnp(0) then change_difficulty(false) end
if btnp(1) then change_difficulty(true) end
if (btnp(4)) then difficulty_selection = false end
if btnp(5) then
set_all_speeds(current_difficulty.speed)
if (testbug1) then
music()
round = testbug1_round
else
music() end
playing = true
end
end
end
if time() - tgameover > 1 and btnp(5) then
if gameover then
_init()
end
if won or allwon then
-- assemble currentfruits into dsets
allfruits_arr = {fruits.grape,fruits.orange,fruits.apple,
fruits.papaya,fruits.banana,
fruits.pineapple, fruits.coconut,
fruits.watermelon,fruits.chirimoya, fruits.acaiberries}
--reset all dsets first
for i=1,10,1 do
dset(i+10, 0)
end
--if not won all, remove last element of array first
-- seems to not work hmm, oh yeah cause need to remove fruits.rest
-- oh yeah2 need to use a on bar updated version
_currentfruits = currentfruits_show
del(_currentfruits,fruits.rest)
if (not allwon and #_currentfruits > 1) then
deli(_currentfruits)
end
for i=1,#_currentfruits do
_ft = _currentfruits[i]
for j=1,#allfruits_arr,1 do
if _ft == allfruits_arr[j] then
dset(i+10,j)
end
end
end
dset(1, perfect_rounds_count)
dset(2, current_level_show)
dset(3, current_difficulty_id)
end
if won then
load(fizzd_path and "chikischefs/ending.p8" or "ending.p8", "back to game", "won")
end
if allwon then
load(fizzd_path and "chikischefs/ending.p8" or "ending.p8", "back to game", "allwon")
end
end
end
function get_offset_ticks()
---s / (s/tick) = tick
-- the 'tick' we mean is length of a note i.e. 16 pico ticks at normal speed
return (input_offset / 1000) / (current_speed * single_tick_length)
end
function play_update()
-- conductor
--detect a stat(50) looping
statprev = tickl
tickl = stat(50)
if (tickl < statprev)
then statloops+=1 end
newtick = tickl ~= statprev
newbar = newtick and tickl == 0
tick = stat(50) + statloops * statcap
-- find one frame worth in the tick domain
-- s / (s / tick) = tick
dtt = dt / (single_tick_length * current_speed)
tickf = newtick and tick or tickf + dtt
anybtn = btnp(0) or btnp(1) or btnp(2) or btnp(3) or btnp(4) or btnp(5)
headbob = tickl % 4 < 1
update_conductor()
-- game logic
t = time() * 2
-- appear conveyor belt fruit
-- if btnp(4) then
-- z = ceil(rnd(#allfruits - 1))
-- bringfruit(allfruits[z])
-- end
if newbar and calltime then
bubblefruits = {}
end
if newbar then
current_level_show = current_level
currentfruits_show = currentfruits
end
-- if anybtn then
-- load("ending.p8", "back to game", "allwon")
-- end
-- appear bubble fruit
--check if current tickl is in the starting beat for a bubble
local flagg = false
--wtf ternary
local _arr = music_side_prebar == mside.a and startbeats_a or startbeats_b
--fruits character position in string
pos = -1
for i=1,#_arr do
if _arr[i] == tickl then
flagg = true
pos = i
end
end
--printh("tickl" .. tickl .. " -> flagg " .. (flagg and "true" or "false") .. " pos " .. pos .. "/ newtick " .. (newtick and "true" or "false") .. " #arr_basket_show " .. #arr_basket_show .. " intro? " .. (music_state ~= mstate.intro and "true" or "false"))
if flagg == true and newtick and calltime and #arr_basket > 0 and music_state ~= mstate.intro then
--z = ceil(rnd(#allfruits - 1))
--pos = flr(tickl / 4) --
--printh(arr_basket_show)
--printh(pos)
ifruit = arr_basket[pos]
--finds the starting beat of the first syllable of the fruits
beatpos = 1
for i = 1, pos - 1 do
f = currentfruits[arr_basket_show[i]]
beatpos = beatpos + #f.syllables
end
if beatpos <= #arr_basket_beats then
beat = arr_basket_beats[beatpos]
f = currentfruits[ifruit]
if #f.notes > 0 then -- don't add rests
addbubblefruit(f, pos, beat)
end
end
end
-- missed beat
if music_state == mstate.response then
for i = #arr_basket_beats_results + 1, #arr_basket_beats_show do
b = arr_basket_beats_show[i]
diff = tickf % 16 - b
if diff > 7 then
arr_basket_beats_results[i] = false
printh("bigmiss..")
str_last_margin = "miss!"
rabbit_state = 1
end
end
end
-- game over
if gameover == false and won == false and allwon == false and newtick and tickl == 2 then
if (not testbug1 and not godmode) then
misses = max(0, (round - 1) - perfect_rounds_count)
else
misses = 0
end
lives = maxlives - misses
printh("misses: " .. misses)
if misses >= maxlives then
printh("gameover")
if current_level >= 3 then
won = true
rabbit_state = 2
else
gameover = true
end
tgameover = time()
music(-1)
sfx(62)
end
end
-- scratch!
if anybtn and gameover == false then
tscratch = 0
tcatanim = 0
nextbeat = #arr_basket_beats_results + 1
-- check beats
--but first , check if should ignore the scratch
local shouldcount = true
printh("-------")
printh(tickl)
if (music_state == mstate.call and ( tickl > 2 and tickl < 13))
then shouldcount = false end
printh(shouldcount)
if nextbeat <= #arr_basket_beats_show and shouldcount then
b = arr_basket_beats_show[nextbeat]
---s / (s/tick) = tick
-- the 'tick' we mean is length of a note i.e. 16 pico ticks at normal speed
local offset_ticks = get_offset_ticks()
local tickf_adj = tickf - offset_ticks --i.e. negative means you get to hit earlier
tickfl = tickf_adj % 16
-- basket beats are 1-indexes, tick is 0 indexed!!
diff = b - 1 - tickfl
b_adj = b
if diff < tickfl and abs(diff) > 8 then
b_adj = b + 16 --must be adj cause we are using b again below
-- printh("dddd")
end
diff = b_adj - 1 - tickfl
absdiff = abs(diff)
printh("b " .. b)
-- check whats the closest fruit to hit
closestfruit = 1
for i = 1, #bubblefruits do
f1 = bubblefruits[i]
f2 = bubblefruits[closestfruit]
if abs(f1.beat - b) < abs(f2.beat - b) then
closestfruit = i
end
end
--^ this is imperfect cause it checks the starting syllables
-- also b is not the current beat but the supposed beat of the next slice, why?
-- quick hack to revert to prev if still alive
-- testbug1 unrelated to this, tested
if closestfruit > 1 and bubblefruits[closestfruit-1].lives > 0
and abs(bubblefruits[closestfruit-1].beat - b) < 6 --max 5 beats from starting syllable to end
then
closestfruit -= 1
end
-- hit correctly
if absdiff < hit_margin then -- set in change_difficulty
printh("hit! " .. diff)
arr_basket_beats_results[nextbeat] = true -- i.e. adds array length!
if #bubblefruits > 0 then
bubblefruits[closestfruit].tglow = 0.1 end
-- change rabbit to happy if it wasn't angry
if rabbit_state == 0 then
rabbit_state = 2
end
-- create slice
-- error avoiding if scratch right when bubblefruits was reset
-- (cause bubblefruits is reset without offset adjustment)
if #bubblefruits > 0 then
f = bubblefruits[closestfruit]
f.tfreeze = 0.2
f.lives = f.lives - 1
addslice(closestfruit)
end
if #arr_basket_beats_results == #arr_basket_beats_show then
perfect_round = true
for i = 1, #arr_basket_beats_results do
if arr_basket_beats_results[i] == false then
perfect_round = false
end
end
if perfect_round then
perfect_rounds_count = perfect_rounds_count + 1
-- sfx(33) disable cause no channels
dset(0, max(perfect_rounds_count, dget(0)))
end
else
perfect_round = false
end
-- small miss
elseif absdiff < 7 then
if (diff < 0 ) then str_last_margin = "late!"
else str_last_margin = "early!" end
printh("smallmiss.." .. diff)
rabbit_state = 1
arr_basket_beats_results[nextbeat] = false
-- no beats close
else
printh("nothing.." .. diff)
end
end
end
if tscratch >= 0 then
tscratch += dt * 20
if tscratch > 3 then tscratch = -1 end
end
if tcatanim >= 0 then
tcatanim += dt * 30
if tcatanim > 3 then tcatanim = -1 end
end
-- update fruits position on conveyor belt
for i = 1, #currfruits do
f = currfruits[i]
f.x = f.x - 0.5
if f.x < 69 then
del(currfruits, f)
break
end
end
-- update fruits position on bubbles
updatefruits()
updateslices()
end
function _draw()
-- clean screen
-- if rabbit_state == 0 then
-- cls(4)
-- elseif rabbit_state == 1 then
-- cls(8)
-- elseif rabbit_state == 2 then
-- cls(11)
-- end
cls(4)
-- draw the backstage
map(0, 0, 0, 0, 16, 16)
-- draw board legs
xboard = 68
yboard = 110
for i = 0, 3 do
line(
xboard + 7 + i,
yboard + 0,
xboard + 0 + i,
yboard + 18,
9)
line(
xboard + 18 + i,
yboard + 0,
xboard + 18 + i,
yboard + 18,
9)
line(
xboard + 29 + i,
yboard + 0,
xboard + 36 + i,
yboard + 18,
9)
end
-- draw board marker holder
rectfill(
xboard + 12,
yboard - 1,
xboard + 27,
yboard + 1,
6)
bstat = stat(50) - get_offset_ticks()
-- draw fruit texts
if gameover == false and won == false and allwon == false then
sylcount = 0
for i = 1, #arr_basket_show do
ifruit = arr_basket_show[i]
f = currentfruits[ifruit]
sylaudio = 0
for j = 1, #arr_basket_beats_show do
if bstat + 1 >= arr_basket_beats_show[j] then
sylaudio = j
end
end
word_results = {}
-- render text on blackboard
for j = 1, #f.notes do
if calltime then -- call time
result_int = sylaudio - sylcount >= j and 2 or 0
add(word_results, result_int)
else -- response time
results_index = sylcount + j
if results_index <= #arr_basket_beats_results then
result = arr_basket_beats_results[results_index]
result_int = result == true and 2 or 1
add(word_results, result_int)
else
add(word_results, 0)
end
end
end
textfruit(f, i - 1, word_results)
sylcount = sylcount + #f.notes
end
end
--test case
if (testwin) then
round = 4
playing = true
current_difficulty_id = 4
current_difficulty = game_difficulties.very_hard_plus
won = true
current_level = 5
currentfruits = {fruits.apple,fruits.orange, fruits.chirimoya, fruits.grape}
end
if (testbug1) then
current_level = testbug1_level
end
if gameover == true then
print("game over!", 68,66, 7)
print("press ❎ to\n restart", 66,80, 10)
print("score: " .. perfect_rounds_count, 62, 101, 7)
elseif won == true then
print("nicely done!", 65,66, 7)
print("press ❎ to\n continue", 66,80, 10)
print("score: " .. perfect_rounds_count, 62, 96, 7)
if (current_difficulty_id > 3) then
print("(" .. current_difficulty.name .. ")", 62, 102) end
elseif allwon == true then
print("you are\namazing!", 72,60, 7)
print("press ❎ to\n continue", 66,76, 10)
color = perfect_rounds_count == 32 and 10 or 7
print("score: " .. perfect_rounds_count, 62, 96, color)
if (current_difficulty_id > 3) then
print("(" .. current_difficulty.name .. ")", 62, 102) end
elseif playing == false then
if not difficulty_selection then
print("chiki's chefs", 62,62, 7)
print("press ❎ to\n start", 66,72, 10)
print("offset:\n⬅️".. input_offset.. " ms➡️(⬇️)",62,87, 7)
hiscore = dget(0)
if hiscore == 32 then
color = time() % 1.0 < 0.5 and 10 or 9
else
color = 7
end
print("hi score: " .. hiscore, 62, 101, color)
else
print("press ❎ to\n start", 66,72, 10)
print("difficulty:\n⬅️".. current_difficulty.name .. "➡️",62,87, 7)
end
end
-- draw result checkmark
if (tick % 2 == 0 or tickl < 8) and won == false and gameover == false and allwon == false then
if perfect_round then
spr(12, 97, 92, 2, 2)
elseif rabbit_state == 1 then
spr(14, 97, 92, 2, 2)
end
-- printh("perfect round")
end
-- draw score
if playing == true and won == false and gameover == false and allwon == false then
if round == 0 then
print("follow the\n rhythm!", 68, 67, 10)
print("press ❎ to\n slice", 67, 90, 7)
else
if (music_state ~= mstate.response) then
print("score: " .. perfect_rounds_count, 62, 101, 7)
else
print(str_last_margin, 62, 101, 7)
end
end
end
-- scratch
if tscratch >= 0 then
sprnum = flr(tscratch)
sprind = 154 + sprnum * 2
xscratch = 13 + (closestfruit - 1) * bubbles_xoffset
spr(sprind, xscratch, 58, 2, 3)
end
-- cat
altrender(true)
xcat = 3
ycat = 64
if tcatanim >= 0 then
sprnum = flr(tcatanim)
sprind = 114 + sprnum * 3
xcat = xcat + sprnum / 1.5
spr(sprind, xcat, ycat, 3, 2)
else
sprcat = headbob and 120 or 112
spr(sprcat, xcat, ycat, 2, 2)
end
altrender(false)
-- cat chef hat
cy = headbob and 1 or 0
spr(69, xcat + 2, ycat - 3 + cy)
-- frog
altrender(true)
openmouth = false
if calltime then
for i = 1, #bubblefruits do
if tickl == bubblefruits[i].tick % 16 then
openmouth = true
end
end
end
sprfrog = 146
if openmouth then
sprfrog = 148
elseif headbob then
sprfrog = 144
end
spr(sprfrog, 8 * 8, 3 * 8, 2, 2)
altrender(false)
-- frog chef hat
xfroghat = openmouth and 7 or 6
yfroghat = headbob and 1 or 0
spr(69, xfrog + xfroghat, yfrog - 10 + yfroghat, 1,1, true)
-- bowl back
xbowl = 10
ybowl = 128 - 2 * 8
bowlcolor = 5
if current_level == 2 then bowlcolor = 14 end
if current_level == 3 then bowlcolor = 2 end
if current_level >= 4 then bowlcolor = 1 end
ovalfill(xbowl + 2, ybowl, xbowl + 6 * 8 - 2, ybowl + 4, bowlcolor)
-- fruits
drawfruits()
-- slices
drawslices()
-- bowl front
altrender(true)
bowlcolor = 6
if current_level == 2 then bowlcolor = 15 end
if current_level == 3 then bowlcolor = 8 end
if current_level >= 4 then bowlcolor = 12 end
pal(12, bowlcolor)
spr(80, xbowl, ybowl, 6, 2)
pal(12, 12)
altrender(false)
-- rabbit
if playing == true then
trabbitappear = min(trabbitappear + 3/60, 1)
altrender(true)
xrabbit = 96
yrabbit = 97 + lerpquad(32, 0, trabbitappear)
if headbob then yrabbit = yrabbit + 1 end
if rabbit_state == 0 then spr(199, xrabbit, yrabbit, 4,4)
elseif rabbit_state == 1 then spr(196, xrabbit + 8, yrabbit, 3,4)
elseif rabbit_state == 2 then spr(192, xrabbit, yrabbit, 4,4)
end
end
altrender(false)
-- bubble
-- t = (sin(time()) + 1) * 5
-- r = t
-- drawbubble(25, 25, r)
-- lives
circfill(7,7, 6, 0)
circfill(7,7, 5, 8)
print(lives, 6,5, 7)
-- debug
if (testbug1) then
printdebug() end
-- drawresultsquares()
end
function drawbubble(x, y, r)
circ(x, y, r, 12) -- inner circle
circ(x, y, r + 1, 7) -- outer circle
-- specular highlight
sx = x - r * 0.5
sy = y - r * 0.5
rectfill(sx, sy, sx + 1, sy + 1, 7)
end
function drawresultsquares()
for i = 1, #arr_basket_beats_show do
b = arr_basket_beats_show[i]
x = 52 + i * 5
y = 67
w = 3
h = 3
color = 7
if music_state == mstate.call or i > #arr_basket_beats_results then
rect(x, y, x + w, y + h, 7)
else
rs = arr_basket_beats_results[i]
color = rs == true and 11 or 8
rectfill(x, y, x + w, y + h, color)
end
end
end
function altrender(set)
palt(2, set)
palt(0, not set)
end
function printdebug()
-- reset to color white
print("", 0,0, 7)
-- print("fps ".. stat(7))
-- print("arr_basket " .. arr_basket)
-- print("")
-- print("blackboard:")
-- sss = ""
-- for i = 1, #arr_basket_beats do
-- sss = sss .. "\n" .. arr_basket_beats[i]
-- end
-- print(sss, 0,10)
print("stat(50) " .. stat(50), 0, 0)
print("stat(54) " .. stat(54))
print("state "..music_state)
-- print("side prebar "..music_side_prebar)
-- print("side "..music_side_show)
print("round "..round)
print("tick " .. tick)
print("tickf ".. tickf)
print("sylaudio ".. sylaudio)
print("level: "..current_level)
print("level: "..current_level_show)
end
function addslice(fruitindex)
f = bubblefruits[fruitindex]
s = {
x = f.x - 4 + rnd(4),
y = f.y,
sprite = f.data.slicesprite,
w = f.data.slicesize.x,
h = f.data.slicesize.y,
ymax = 110 + rnd(7)
}
add(slices, s)
--printh("spr " .. f.data.slicesprite)
--printh("adding new slice -> " .. f.data.name .. " at " .. f.x .. ", " .. f.y)
end
function updateslices()
for i = 1, #slices do
s = slices[i]
s.y = min(s.y + 2, s.ymax)
end
end
function drawslices()
for i = 1, #slices do
s = slices[i]
spr(s.sprite, s.x - 4, s.y - 4, s.w, s.h)
--printh("drawing -> " .. s.sprite .. " at " .. s.x .. ", " .. s.y)
end
end
function bringfruit(fruit)
currfruits[#currfruits + 1] = {
x = 120,
y = 32,