This repository was archived by the owner on Oct 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgame.lua
More file actions
1278 lines (1071 loc) · 25.8 KB
/
game.lua
File metadata and controls
1278 lines (1071 loc) · 25.8 KB
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
-- title: Katzu
-- author: kleeder, Nimo, BotA, alili1996
-- desc: BotB Game Jam 3
-- script: lua
-- t: updates every frame (60fps)
-- modes: used to change current state of game
t = 0
mode_menu = 1
mode_prelevel = 2
mode_level = 3
mode_music = 4
mode_clear = 5
mode_done = 6
mode_playMusic = 7
mode_controls = 8
mode_debug = false
mode=mode_menu
woolStringLength = {2400,2000,2500,2700,4000} -- for each level
size = 0 --unnötig nötige variable für die destroy animation
playerStartPos = {
{10, 88, 10, 88, 10, 72, 10, 120, 0, 0, 0, 0, 0, 0}, --level 1: Room 1 x,y, Room 2 x,y, x3,y3, ...
{10, 120, 10, 120, 10, 112, 10, 104, 10, 40, 0, 0, 0, 0}, --level 2: ...
{10, 88, 10, 104, 10, 48, 10, 112, 10, 120, 10, 0, 10, 0},
{10, 104, 10, 104, 10, 88, 10, 56, 10, 112, 10, 0, 10, 0},
{10, 96, 10, 80, 10, 88, 10, 24, 10, 72, 10, 72, 10, 0}}
woolStartPos = {
{24, 88, 24, 88, 24, 72, 24, 120, 0, 0, 0, 0, 0, 0}, --level 1:
{24, 120, 24, 120, 24, 112, 24, 104, 24, 40, 0, 0, 0, 0}, --level 2: ...
{24, 96, 24, 104, 24, 48, 24, 112, 24, 120, 24, 0, 24, 0},
{24, 104, 24, 104, 24, 88, 24, 56, 24, 112, 24, 0, 24, 0},
{24, 96, 24, 80, 24, 88, 24, 24, 24, 72, 24, 72, 24, 0}}
function init()
solids={[2]=true,[3]=true}
levelCounter = 0 -- increments after every finished level
levelCounter = pmem(1) --loading save
music (1,0,7,false) --menu theme
p={
x=0,
y=0,
vx=0, --Velocity X
vy=0, --Velocity Y
o =0, --orientation
f =0, --falling
p =0, --punch
}
initHold = false
--cam={x=120,y=68}
--Jumping physics
btn0released = true
inRoomNr = 64
rooms = {}
for y = 0,136-17,17 do
for x = 0,240-30,30 do
table.insert(rooms, {x,y})
end
end
end
function rget(i)
return rooms[i][1],rooms[i][2],30,17
end
-- mget recalculation for rooms
function mget2(x,y, room)
return mget(x+30*((room-1)%8), y + 17*((room-1)//8))
end
function setRoomNr(roomNr)
inRoomNr = roomNr
end
-- is block id solid? for player
function isSolid(id)
return id >= 1 and id <= 79 or id >= 227 and id <= 230 or id >= 241 and id <= 246 or id >= 232 and id <= 234 or id == 247--#032-#079: Solid // also id 253: destroy-block
end
-- is block id solid? for wool
function isSolidWool(id)
return id >= 1 and id <= 79 or id >= 248 and id <= 251 --#032-#079: Solid // also id 253: destroy-block
end
function ishalfSolidWool(id)
return id >= 80 and id <= 111
end
function isHalfSolid(id)
return id >= 80 and id <= 111
end
-- is a block at x,y solid? (actual map view)
function solid(x,y)
return isSolid(mget2((x)//8,(y)//8, inRoomNr))
end
function halfSolid(x,y)
return isHalfSolid(mget2((x)//8,(y)//8, inRoomNr))
end
--function solid(x,y)
-- return isSolid(mget2((x)//8,(y)//8, inRoomNr))
--end
function solidInRoom(x,y, room)
return isSolidWool(mget2((x)//8,(y)//8, room))
end
function halfSolidInRoom(x,y, room)
return ishalfSolidWool(mget2((x)//8,(y)//8, room))
end
function getGroundHeight(x, y)
while (not solidInRoom(x ,y , w.room) and (not halfSolidInRoom(x ,y , w.room)))
and (not solidInRoom(x-1 ,y , w.room) and (not halfSolidInRoom(x-1 ,y , w.room))) and y < 132 do -- 240 under level
y = y + 1
end
return y
end
function spawnPlayer()
p={
x=20,
y=0,
vx=0, --Velocity X
vy=0, --Velocity Y
o =0, --orientation
f =0, --falling
p =0, --punch
}
inRoomNr = 2 + levelCounter * 8
p.x = playerStartPos[(levelCounter+1)][1]
p.y = playerStartPos[(levelCounter+1)][2]
end
function spawnWool(currentRoom)
w={
x = 28,
y = 0,
vx= 0,
vy= 0,
r = 0,
room = currentRoom+1,
goal = false,
size = 0,
track = {},
length = {},
respawn = false,
stringLength = 0
}
w.x = woolStartPos[(levelCounter+1)][1]
w.y = woolStartPos[(levelCounter+1)][2]
--w.stringLength =
end
function isPointInBlockID(x,y,room, id)
return mget2((x)//8,(y)//8, room) == id
end
--check if a Sprite 8x8 touches a Block with the ID
function isWoolInBlockId(id)
return isPointInBlockID(w.x+w.vx+4,w.y+w.vy, w.room, id) or isPointInBlockID(w.x+4,w.y+w.vy, w.room, id)
or isPointInBlockID(w.x+4+w.vx,w.y+4+w.vy, w.room, id) or isPointInBlockID(w.x+w.vx+4,w.y+4+w.vy, w.room, id)
end
-- draws a parabel between 2 points
function cLine(x1,y1,x2,y2, color)
if x1 == -1 or x2 == -1 then
return
end
if x2 < x1 then
temp = x2
x2 = x1
x1 = temp
temp = y2
y2 = y1
y1 = temp
end
dx = x2 - x1
dy = y2 - y1
trackX = {}
trackY = {}
counter = 0
if y1 >= y2 then
for x = x1, x2, 1 do
y = y1 + dy/(dx*dx) * (x - x1) * (x - x1)
--pix(x,y,color)
trackX[counter] = x
trackY[counter] = y
counter = counter + 1
--line(ox, oy, x, y, color)
end
else
for x = x1, x2, 1 do
y = y2 - dy/(dx*dx) * (x - x1) * (x - x1)
--pix(x2-(x-x1),y,color)
trackX[counter] = x2-(x-x1)
trackY[counter] = y
counter = counter + 1
--line(ox, oy, x, y, color)
end
end
for p=1, counter-1, 1 do
line(trackX[p-1], trackY[p-1], trackX[p], trackY[p], color) --connects pixels of parabel
end
end
-- is a wool at x,y? (actual map view)
function woolRight(x,y)
return (math.abs(p.x+7-w.x)<0.5 and math.abs(p.y-w.y)<0.5)
end
function woolLeft(x,y)
return (math.abs(p.x-7-w.x)<0.5 and math.abs(p.y-w.y)<0.5)
end
function woolInGoal(x,y)
if mget2((x)//8,(y)//8, w.room) == 254 or mget2((x)//8,(y)//8, w.room) == 253 or mget2((x)//8,(y)//8, w.room) == 252 or mget2((x)//8,(y)//8, w.room) == 238 then
--set wool state to small/ fix pos -> end
print("Level cleared!",81,26,0)
print("Level cleared!",80,25,15)
spr(255, (x//8)*8, (y//8)*8, 2, 1, 0, 0, 1, 1)
w.size = 3
w.goal = true
line((x//8)*8 ,(y//8)*8+7 ,(x//8)*8+3,(y//8)*8+2,68)
end
end
function respawn()
p.o= 0
--p.x = playerStartPos[(levelCounter) * 2 +1]
--p.y = playerStartPos[(levelCounter) * 2 +2]
offset = inRoomNr - (2 + levelCounter * 8)
p.vy = 0
p.x = playerStartPos[(levelCounter+1)][1+offset*2]
p.y = playerStartPos[(levelCounter+1)][2+offset*2]
end
function respawnLevel()
p.o= 0
inRoomNr = 2 + levelCounter * 8
p.vy = 0
p.x = playerStartPos[(levelCounter+1)][1]
p.y = playerStartPos[(levelCounter+1)][2]
end
function resetLevel(levelCounter)
setRoomNr( 2 + levelCounter * 8 ) -- 2 10 18 26 24
end
--WOOL
-- wool physics
function woolUpdate()
-- switch to next room
if w.x < 0 and w.room == 2 or w.x < 0 and w.room == 10 or w.x < 0 and w.room == 18 or w.x < 0 and w.room == 26 or w.x < 0 and w.room == 34 then
w.x = 0
w.room = w.room
elseif w.x > 240 then
w.x = w.x - 240
w.room = w.room + 1
w.vx = w.vx + 1
elseif w.x < 0 and w.room > 1 then
w.x = 232
w.room = w.room - 1
w.vx = w.vx - 1
end
if w.y > 127 and w.room == inRoomNr then
sfx(24,F5,-1,3,15,0)
respawnWool()
end
--specialBlocks
--destroy
if isWoolInBlockId(227) or isWoolInBlockId(228) or isWoolInBlockId(229) or isWoolInBlockId(230) or isWoolInBlockId(241) or isWoolInBlockId(242) or isWoolInBlockId(243) or isWoolInBlockId(244) or isWoolInBlockId(245) or isWoolInBlockId(246) then
destroyWool()
end
-- gravity
if solidInRoom(w.x,w.y+8+w.vy, w.room) or solidInRoom(w.x+7,w.y+8+w.vy, w.room) then
w.vy=0
elseif halfSolidInRoom(w.x,w.y+8+w.vy, w.room) or halfSolidInRoom(w.x+7,w.y+8+w.vy, w.room) then
w.vy=math.min(0, w.vy)
else
w.vy=w.vy+0.2
end
--wall left right
if solidInRoom(w.x+w.vx,w.y+w.vy, w.room) or solidInRoom(w.x+7+w.vx,w.y+w.vy, w.room)
or solidInRoom(w.x+w.vx,w.y+7+w.vy, w.room) or solidInRoom(w.x+7+w.vx,w.y+7+w.vy, w.room) then
w.vx=0
end
if math.abs(w.vx) < 0.1 then
w.vx = 0
end
if w.size <= 1 and w.respawn == false then
print("Wool empty!",81,36,0)
print("Wool empty!",80,35,15)
w.vx=0
--w.vy=0
end
if w.goal == false then
w.x=w.x+w.vx
w.y=w.y+w.vy
end
if math.abs(w.vx) > 0.01 or math.abs(w.vy) > 0.01 then
w.track[w.room][w.length[w.room]*2] = w.x//8*8 --save coordinates in table, alternate x1,y1,x2,y2,...
w.track[w.room][w.length[w.room]*2 + 1] = getGroundHeight(w.x//8*8, w.y)
w.length[w.room] = w.length[w.room] + 1
w.stringLength = w.stringLength + math.abs(w.vx)
end
--calc woolSize with the diff of the level max length (woolStringLength) - 5 sizes
if w.respawn == false then
w.size = math.max(0,math.ceil(((woolStringLength[levelCounter+1] - w.stringLength) / woolStringLength[levelCounter+1]) * 4))
end
--print(math.ceil(((woolStringLength[levelCounter+1] - w.stringLength) / woolStringLength[levelCounter+1]) * 4) ,100,110,14)
--print(w.length[inRoomNr] ,140,110,14)
--print(w.y ,80,110,14)
--needel
woolInGoal(w.x,w.y)
--print(w.length[inRoomNr],100,110,14)
end
function sign(int)
if int < 0 then
return -1
else
return 1
end
end
-- vector from cat to wool
function throwWool()
if inRoomNr == w.room then
if sign((w.x-p.x)) == 1 and p.o == 0 or sign((w.x-p.x)) == -1 and p.o == 1 then
sfx(20,F5,-1,3,15,0)
w.vx = sign((w.x-p.x)) * 3 -- width: 3
w.vy = -3 --(w.y-p.y) -- height: 3
end
p.p = 14
end
end
function pullWool()
if inRoomNr == w.room then
if sign((w.x-p.x)) == 1 and p.o == 0 or sign((w.x-p.x)) == -1 and p.o == 1 then
sfx(21,F5,-1,3,15,0)
w.vx = sign((w.x-p.x)) * -2 -- width: 3
w.vy = 0 -- height: 0
end
p.p = 14
end
end
function destroyWool()
w.respawn = true
end
function resetLevel()
w.room = 2 + levelCounter * 8
for i = 0, 6, 1 do
w.track[w.room + i] = {}
w.length[w.room + i] = 0
end
w.stringLength = 0
w.vx = 0
w.vy = 0
w.x = woolStartPos[(levelCounter+1)][1]
w.y = woolStartPos[(levelCounter+1)][2]
end
function respawnWool()
w.vx = 0
w.vy = 0
offset = inRoomNr - (2 + levelCounter * 8) --w.room??
w.x = woolStartPos[(levelCounter+1)][1+offset*2]
w.y = woolStartPos[(levelCounter+1)][2+offset*2]
w.track[inRoomNr][(w.length[w.room]-1)*2] = -1
w.track[inRoomNr][(w.length[w.room]-1)*2+1] = -1
end
function drawWoolString(x, y)
if w.length[inRoomNr] > 1 then
for x = 1, w.length[inRoomNr]-1, 1 do
cLine(w.track[inRoomNr][(x-1)*2], w.track[inRoomNr][(x-1)*2+1],
w.track[inRoomNr][x*2], w.track[inRoomNr][x*2+1], 276) --pix(w.track[x*2], w.track[x*2+1], 276)
end
if w.room == inRoomNr then
if w.track[inRoomNr][(w.length[w.room]-1)*2] == -1 then
return
end
line(w.track[inRoomNr][(w.length[w.room]-1)*2], w.track[inRoomNr][(w.length[w.room]-1)*2+1], w.x+4, w.y+6 , 276)
end
end
end
-- WOOL END
function resetHandler()
-- reset progress
if btn(6) or key(18) then
--reset room
respawnWool()
respawn()
--reset full level?
if sc_reset > 0 then
print("reset level?", 5,8,0)
print("reset level?", 4,7,15)
print(""..sc_reset.."/100", 16, 18, 0)
print(""..sc_reset.."/100", 15, 17, 15)
end
if sc_reset == 99 then
sfx(25,C4,-1,3,15,0)
end
if sc_reset == 100 then
print("Reset!", 18, 28, 0)
print("Reset!", 17, 27, 15)
resetLevel(levelCounter)
resetLevel() --overloading of func name :/
respawnLevel()
sc_reset=100
else
sc_reset=sc_reset+1
end
else
sc_reset=-25
end
--if btnp(6) or keyp(18) then
-- resetLevel(levelCounter)
-- respawnWool()
-- respawn()
-- end
end
--Map stuff
-- check if a value is in a table, thx Oka, stackoverflow
function has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
function animateBlocks()
-- animation with 2 sprites, second spirte should have the id + 1
-- use the first sprite in the map editor
animatiedBlocks = {160, 192, 208} -- only the first id, that is on the map (lava, water)
for y = 0,17,1 do
for x = 0,30,1 do
tile = mget2(x,y, inRoomNr)
if has_value(animatiedBlocks, tile) then
spr(tile + (t/13)%2 ,x*8,y*8) -- t/13 magic number, -> slow animation
end
end
end
end
-- Map end
-- MUSIC
function playMusic()
f1=peek(0xFF9C)|((peek(0xFF9D)&0x0F)<<8)
v1=peek(0xFF9D)>>4
f2=peek(0xFFAE)|((peek(0xFFAF)&0x0F)<<8)
v2=peek(0xFFAF)>>4
f3=peek(0xFFC0)|((peek(0xFFC1)&0x0F)<<8)
v3=peek(0xFFC1)>>4
f4=peek(0xFFD2)|((peek(0xFFD3)&0x0F)<<8)
v4=peek(0xFFD3)>>4
fx1=(math.log(f1)-min)/(max-min)
fx2=(math.log(f2)-min)/(max-min)
fx3=(math.log(f3)-min)/(max-min)
fx4=(math.log(f4)-min)/(max-min)
cls(1) --background tile color
--map(0,0,8,8,175,1)
rect(1,1,82,134,11) --border box left
rect(2,2,80,132,8) --color left box
line(11,4,11,130,3) --border 1st line
line(31,4,31,130,3) --border 2nd line
line(51,4,51,130,3) --border 3rd line
line(71,4,71,130,3) --border 4th line
line(12,4,12,130,7)
line(32,4,32,130,7)
line(52,4,52,130,7)
line(72,4,72,130,7)
rect(13-(v1/2),129-(fx1*124),v1,2,0) --shadows
rect(33-(v2/2),129-(fx2*124),v2,2,0)
rect(53-(v3/2),129-(fx3*124),v3,2,0)
rect(73-(v4/2),129-(fx4*124),v4,2,0)
rect(12-(v1/2),128-(fx1*124),v1,2,2) --1
rect(32-(v2/2),128-(fx2*124),v2,2,5) --2
rect(52-(v3/2),128-(fx3*124),v3,2,14) --3
rect(72-(v4/2),128-(fx4*124),v4,2,15) --4
rect(84,1,67,19,0) --backgrounds waveforms
rect(84,21,67,19,0)
rect(84,41,67,19,0)
rect(84,61,67,19,0)
w=0
w1=0
w2=0
w3=0
w4=0
i1=0
i2=0
i3=0
i4=0
w1=peek(0xFF9E+(i1%16))
w2=peek(0xFFB0+(i2%16))
w3=peek(0xFFC2+(i3%16))
w4=peek(0xFFD4+(i4%16))
while w<64 do
ww1=w1
ww2=w2
ww3=w3
ww4=w4
w1=peek(0xFF9E+(i1%16))
w2=peek(0xFFB0+(i2%16))
w3=peek(0xFFC2+(i3%16))
w4=peek(0xFFD4+(i4%16))
line(85+(w*1),(ww1/-16*(v1/15))+18,86+(w*1),(w1/-16*(v1/15))+18,2)
line(85+(w*1),(ww2/-16*(v2/15))+38,86+(w*1),(w2/-16*(v2/15))+38,5)
line(85+(w*1),(ww3/-16*(v3/15))+58,86+(w*1),(w3/-16*(v3/15))+58,14)
line(85+(w*1),(ww4/-16*(v4/15))+78,86+(w*1),(w4/-16*(v4/15))+78,15)
i1=i1+(f1/300)
i2=i2+(f2/300)
i3=i3+(f3/300)
i4=i4+(f4/300)
w=w+1
end
rect(84,126,155,9,0) --Song Progress Bar Border
-- song progress bar for every track
if track==1 then
rect(85,127,153*((c/20)+(t/(2.4*64)/19)),7,15)
elseif track==2 then
rect(85,127,153*((c/20)+(t/(3.4*64)/19)),7,15)
elseif track==3 then
rect(85,127,153*((c/20)+(t/(1.6*64)/19)),7,15)
elseif track==4 then
rect(85,127,153*((c/20)+(t/(0.2*64)/19)),7,15)
elseif track==5 then
rect(85,127,153*((c/20)+(t/(5.8*64)/19)),7,15)
elseif track==6 then
rect(85,127,153*((c/20)+(t/(0.32*64)/19)),7,15)
end
rect(85,127,153*((c/20)+(t/(7*64)/19)),7,15) --Song Progress Bar
i=0
while i<10 do
if str[1+i] ~= nil then
print(str[1+i],153,8*i+2,10)
print(str[1+i],152,8*i+1,15)
end
i=i+1
end
i=0
ii=ii+0.075
-- back to musicbox-menu
if track==1 then
if t==2928 then
music (1,0,7,false)
mode = mode_music
setRoomNr(42)
t=0
end
end
if track==2 then
if t==4096 then
c=0
t=0
end
end
if track==3 then
if t==1920 then
c=0
t=0
end
end
if track==4 then
if t==240 then
music (1,0,7,false)
mode = mode_music
setRoomNr(42)
t=0
end
end
if track==5 then
if t==7168 then
c=0
t=0
end
end
if track==6 then
if t==384 then
music (1,0,7,false)
mode = mode_music
setRoomNr(42)
t=0
end
end
if btnp(6) or keyp(1) then
music (1,0,7,false)
mode = mode_music
setRoomNr(42)
t=0
end
end
function music_player()
print("Press Key 1-6 to Start Music!",44,103,0)
print("Press Key 1-6 to Start Music!",43,102,15)
print("Press A to go Back to Menu!",49,113,0)
print("Press A to go Back to Menu!",48,112,15)
track=0
if keyp(28) then
mode = mode_playMusic
str={
"- Main Menu -",
"",
"by kleeder",
"",
"",
}
min=math.log(16)
max=math.log(3951)
music (1,0,7,false)
t=0
c=0
i=0
ii=0
track=1
end
if keyp(29) then
mode = mode_playMusic
str={
"- Overworld -",
"",
"by kleeder",
"",
"",
}
min=math.log(16)
max=math.log(3951)
music (0,0,47,true)
t=0
c=0
i=0
ii=0
track=2
end
if keyp(30) then
mode = mode_playMusic
str={
"- Underground -",
"",
"by kleeder",
"",
"",
}
min=math.log(16)
max=math.log(3951)
music (2,4,63,true)
t=0
c=0
i=0
ii=0
track=3
end
if keyp(31) then
mode = mode_playMusic
str={
"- Course Clear -",
"",
"by kleeder",
"",
"",
}
min=math.log(16)
max=math.log(3951)
music (4,0,63,false)
t=0
c=0
i=0
ii=0
track=4
end
if keyp(32) then
mode = mode_playMusic
str={
"- Finale -",
"",
"by kleeder",
"",
"",
}
min=math.log(16)
max=math.log(3951)
music (3,15,63,true)
t=0
c=0
i=0
ii=0
track=5
end
if keyp(33) then
mode = mode_playMusic
str={
"- Ending -",
"",
"by kleeder",
"",
"",
}
min=math.log(16)
max=math.log(3951)
music (5,0,63,false)
t=0
c=0
i=0
ii=0
track=6
end
if btnp(6) or keyp(1) then
mode=mode_menu
setRoomNr(64)
end
end
-- MUSIC END
function controls()
print("Controls:", 96,23,0)
print("Controls:", 95,22,15)
spr(256+t%40//10,22,33,0,1,t%200//100,0,0) -- L/R
print("Arrows L/R:", 36,36,0)
print("Arrows L/R:", 35,35,15)
print("Move", 151,36,0)
print("Move", 150,35,15)
spr(260+t%80//40,22,43,0,1,0,0,0) -- Jump
print("Arrow up:", 36,46,0)
print("Arrow up:", 35,45,15)
print("Jump", 151,46,0)
print("Jump", 150,45,15)
spr(268+t%40//20,22,53,0,1,0,0,0) -- Duck
print("Arrow down:", 36,56,0)
print("Arrow down:", 35,55,15)
print("Sneak", 151,56,0)
print("Sneak", 150,55,15)
spr(264+t%30//15,22,63,0,1,0,0,0) -- Throw
print("D:", 36,66,0)
print("D:", 35,65,15)
print("Throw Wool", 151,66,0)
print("Throw Wool", 150,65,15)
if t%60 > 30 then --Pull
spr(264+t%30//15,22,73,0,1,0,0,0)
else
spr(268,22,73,0,1,0,0,0) -- +t%30//15
end
print("D + Sneak (near Wool):", 36,76,0)
print("D + Sneak (near Wool):", 35,75,15)
print("Pull Wool", 151,76,0)
print("Pull Wool", 150,75,15)
spr(224+t%60//30,22,83,0,1,0,0,0) -- reset
print("R:", 36,86,0)
print("R:", 35,85,15)
print("Reset Room", 151,86,0)
print("Reset Room", 150,85,15)
spr(226,22,93,0,1,0,0,0) -- reset hold
print("R (hold):", 36,96,0)
print("R (hold):", 35,95,15)
print("Reset Level", 151,96,0)
print("Reset Level", 150,95,15)
print("Press Q to go Back to Menu!", 48,111,0)
print("Press Q to go Back to Menu!", 47,110,15)
if keyp(17) then
setRoomNr(64)
mode = mode_menu
end
end
function mainMenu()
if t>224 then
if t%64 < 32 then
spr(360,128,0,0,1,0,0,8,5) --3
else
spr(352,128,0,0,1,0,0,8,5) --Logo
end
end
if t%64 < 32 then
print("Press X to Start!",11,46,0)
print("Press X to Start!",10,45,15)
print("Press A for Musicbox!",116,46,0)
print("Press A for Musicbox!",115,45,15)
end
print("Ver 1.0",0,130,15,true,1,true)
print("by kleeder, Nimo, BotA and alili1996",53,130,15)
--spr(432,5,2,0,1,0,0,8,5) --1
if btnp(5) or keyp(24) then
init()
mode=mode_prelevel
music()
return
end
if btnp(6) or keyp(1) then
mode=mode_music
setRoomNr(42)
return
end
if keyp(17) then
setRoomNr(63)
mode=mode_controls
end
-- delete progress
if levelCounter>0 then
if key(18) then
if sc_reset == 99 then
sfx(25,C4,-1,3,15,0)
end
if sc_reset == 100 then
print("Deleted!", 49, 28, 0)
print("Deleted!", 48, 27, 15)
levelCounter = 0
pmem(1, levelCounter)
sc_reset=100
else
sc_reset=sc_reset+1
end
print("delete progress?", 25,8,0)
print("delete progress?", 24,7,15)
print(""..sc_reset.."/100", 51, 18, 0)
print(""..sc_reset.."/100", 50, 17, 15)
else
sc_reset=0
print("Press Key R", 34,8,0)
print("Press Key R", 33,7,15)
print("to delete", 41,18,0)
print("to delete", 40,17,15)
print("your Progress!", 26,28,0)
print("your Progress!", 25,27,15)
end
elseif key(18) and sc_reset == 100 then
print("Deleted!", 49, 28, 0)
print("Deleted!", 48, 27, 15)
print("delete progress?", 25,8,0)
print("delete progress?", 24,7,15)
print(""..sc_reset.."/100", 51, 18, 0)
print(""..sc_reset.."/100", 50, 17, 15)
else
sc_reset=0
print("Press Key Q", 34,13,0)
print("Press Key Q", 33,12,15)
print("to view Controls", 23,23,0)
print("to view Controls", 22,22,15)
end
end
function clear_cutscene()
if initHold == false then
holdTheLine = 0
initHold = true
end
woolInGoal(w.x,w.y)
if holdTheLine == 200 then
initHold = false
mode=mode_prelevel
music ()
else
holdTheLine = holdTheLine + 1
end
end
function game_done() --TODO
if t >= 36 then
if t%60 < 36 then
spr(360,88,20,0,1,0,0,8,5) --3
else
spr(352,88,20,0,1,0,0,8,5) --Logo
end
print("Congratz, you won the game!",46,66,0)
print("Congratz, you won the game!",45,65,15)
end
if t >= 470 then
print("Press X to continue!",68,86,0)
print("Press X to continue!",67,85,15)
end
if btnp(5) or keyp(24) then
mode=mode_menu
setRoomNr(64)
music (1,0,7,false)
t = 0
return
end
end