-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplayer.bb
2350 lines (1753 loc) · 50.9 KB
/
player.bb
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
AppTitle "Wonderland Adventures Editor"
; Global Definitions
Include "particles-define.bb"
Include "level-define.bb"
Include "menu-define.bb"
Include "adventures-define.bb"
Include "sound-define.bb"
Dim wa3endvoidmodel(5)
Global wa3endvoidtexture
Global wa3endshipmodel
Global wa3endshiptexture
Dim wa3endstarmodel(30)
Global wa3endstartexture
Global wa3endbarren,wa3endbarrentexture,wa3endbarrencloud,wa3endbarrencloudtexture,wa3endjaava,wa3endjaavatexture
Global wa3endwonderland,wa3endwonderlandtexture,wa3endsuntexture
Global wa3endsun
Global wa3enduo,wa3enduotexture
Global DebugDisplay=False
Global TestMode=False
Global TestAdventureFilename$
Global WAEpisode=0 ; 0-editor
; 1-Quest For the Rainbow Shards
; 2-Mysteries of Fire Island
; 3-Planet of the Z-Bots
Global VersionText$ = "v10.04 OpenSource"
Global GlobalDirName$
Global Leveltimer2
If FileType("localsaveon.txt")=1 Or WAEpisode=0
GlobalDirName$="UserData"
CreateDir(GlobalDirName$)
Else
GlobalDirName$= SpecialFolderLocation($1c)+"\Midnight Synergy"
; is the folder valid
If FileType(GlobalDirName$) <> 2 Then
CreateDir(GlobalDirName$)
; GiveDirectoryUserFullAccess(GlobalDirName$)
EndIf
GlobalDirName$ = SpecialFolderLocation($1c)+"\Midnight Synergy\WA POTZ"
EndIf
; is the folder valid
If FileType(GlobalDirName$) <> 2 Then
CreateDir(GlobalDirName$)
; GiveDirectoryUserFullAccess(GlobalDirName$)
EndIf
CreateDir GlobalDirName$+"\Temp"
CreateDir GlobalDirName$+"\Player Profiles"
CreateDir GlobalDirName$+"\Custom"
CreateDir GlobalDirName$+"\Custom\Adventures"
CreateDir GlobalDirName$+"\Custom\Hubs"
; ... also Hubs/Textures/Models/etc
CreateDir GlobalDirName$+"\Custom\Editing"
CreateDir GlobalDirName$+"\Custom\Editing\Archive"
CreateDir GlobalDirName$+"\Custom\Editing\Current"
CreateDir GlobalDirName$+"\Custom\Downloads Inbox"
CreateDir GlobalDirName$+"\Custom\Downloads Outbox"
CreateDir GlobalDirName$+"\Custom\Leveltextures"
CreateDir GlobalDirName$+"\Custom\Icons"
Global waterplane,waterplanetexture,cloudplane,cloudplanetexture
Goto skiplocker
Dim lockertext$(4)
;If (Upper$(Mid$(CurrentDate$(),4,3))<>"SEP" And Upper$(Mid$(CurrentDate$(),4,3))<>"OCT") Or FileType("Local")=0
; expire
; Restore expired
; Read a$
; Print a$
; Print "-------------------------------"
; Read a$
; Print a$
; Read a$
; Print a$
; DeleteFile "local"
; Delay 5000
; End
;EndIf
;Print "This is Version BETA2 of"
;Print "Wonderland Adventures: Planet of the Z-Bots"
;Print "-------------------------------------------"
;Print ""
;Print "NOT FOR DISTRIBUTION"
;Print ""
;Print "www.midnightsynergy.com"
;Delay 3000
Goto skiplocker
If lockercrypt()=False
Restore nolockercrypt
Read a$
Print a$
Print "-------------------------------"
Read a$
Print a$
Read a$
Print a$
DeleteFile "local"
Delay 5000
End
EndIf
.skiplocker
If WAEpisode=0
; Check for New Compiled Levels
CheckForNewCompiledLevels(False)
; Check for New Compiled Hubs
CheckForNewCompiledHubs(False)
EndIf
Global FullVersion=True
Global PortalVersion=False ;1-true, 0-false
Global AffiliateID=0
Global ExitAfterTrailer=False
Global TrailerAlreadyPlayed=False
Global TimeOfLastGameSaved=0
Global ExitAfterThisSave=False
Global GfxWidth=800;1280;800;1280;640
Global GfxHeight=600;960;600;768;480
Global GfxDepth=16
Global GfxWindowed=1
Global OldGfxWIndowed
Global NofMyGfxModes, MyGfxMode
Dim MyGfxModeWidth(1000),MyGfxModeHeight(1000),MyGfxModeDepth(1000)
Global FPSDisplay=False
Global MidnightVault=0
Global MidnightVaultTimer
Global WallBlinking=False
Global BackSpaceDown
Global LevelFormat104=False
Global Menukeydown=False
Global StarterItems
Global scoreflag
file=ReadFile (globaldirname$+"\display.wdf")
If file>0
j=ReadInt(file)
For i=0 To j-1
MyGfxModeWidth(i)=ReadInt(file)
MyGfxModeHeight(i)=ReadInt(file)
MyGfxModeDepth(i)=ReadInt(file)
Next
mygfxmode=ReadInt(file)
GfxWindowed=ReadInt(file)
GfxWidth=MyGfxModeWidth(mygfxmode)
GfxHeight=MyGfxModeHeight(mygfxmode)
GfxDepth=MyGfxModeDepth(mygfxmode)
; something is wrong withe graphics mode: try different versions
If GfxMode3DExists (GfxWidth,GfxHeight,GfxDepth)=False
GfxWidth=800
GfxHeight=600
GfxDepth=16
EndIf
If GfxMode3DExists (GfxWidth,GfxHeight,GfxDepth)=False
GfxWidth=800
GfxHeight=600
GfxDepth=32
EndIf
If GfxMode3DExists (GfxWidth,GfxHeight,GfxDepth)=False
GfxWidth=640
GfxHeight=480
GfxDepth=16
EndIf
If GfxMode3DExists (GfxWidth,GfxHeight,GfxDepth)=False
GfxWidth=640
GfxHeight=480
GfxDepth=32
EndIf
Else
GfxWidth=800
GfxHeight=600
GfxWindowed=1
GfxDepth=16
EndIf
;widescreen
Global widescreen=False
Global wideicons=True
Global FitForWidescreenGlobal ;read from master.dat
Global FitForWidescreenGlobalHub ;reserved when starting an adventure in a custom hub
Global FitForWidescreen ;read from .wlv
ratio#=Float(GfxWidth)/Float(GfxHeight)
If ratio#>1.77 And ratio#<1.78 ;aspect ratio must be 16:9
widescreen=True
EndIf
Global NoOfShards=7
Global CustomShardEnabled
Dim CustomShardCMD(NoOfShards,5)
Global CustomShardEnabledHub
Dim CustomShardCMDHub(NoOfShards,5)
;Dim CustomShardData1(NoOfShards)
;Dim CustomShardData2(NoOfShards)
;Dim CustomShardData3(NoOfShards)
;Dim CustomShardData4(NoOfShards)
Global NoOfGlyphs=5
Global CustomGlyphEnabled
Dim CustomGlyphCMD(NoOfGlyphs,5)
Global CustomGlyphEnabledHub
Dim CustomGlyphCMDHub(NoOfGlyphs,5)
Global CustomMapName$
If GfxMode3DExists (GfxWidth,GfxHeight,GfxDepth)=False
Print "Unable to set graphics mode!"
Print ""
Print "Please ensure that your video card drivers"
Print "are up-to-date, or use the graphic options"
Print "to select a different display mode."
Print ""
Print "Exiting... press any key."
WaitKey()
End
EndIf
Global KeyboardMode=2 ; 1- mouse only, 2- mouse/keyboard, 3- gamepad?
Global MouseGameMode=-1 ; What Game Mode the Mouse is Responsive to
; -1 = responsive to movement, icons, anything
; -2 = non responsive - wait for button release
Global Mouse1, Mouse2, EscPressed
Global Tween#,TweenPeriod,TweenTime,TweenElapsed,TweenTicks
Global justregainedfocus
Type AltXType
Field KeyPressed, InUse, Reset
Field X#,Y#,Z#
Field Roll#,Yaw#,Pitch#
End Type
Global AltX.AltXType=New AltXType
Dim ConsoleData(6)
; global ini file
OldGfxWindowed=GfxWindowed
; Main
Graphics3D GfxWidth,GfxHeight,GfxDepth,GfxWindowed
SetBuffer BackBuffer()
HidePointer
file=ReadFile(globaldirname$+"\global.wdf")
If file=0
PlayerName$=""
PlayerCharacterName$=""
GlobalSoundVolume2=5
GlobalMusicVolume2=3
KeyBoardMode=2
DialogContrast=0
Else
playername$=ReadString$(file)
playercharactername$=ReadString$(file)
GlobalSoundVolume2=ReadInt(file)
GlobalMusicVolume2=ReadInt(file)
KeyboardMode=ReadInt(file)
DialogContrast=ReadInt(file)
CloseFile file
GlobalSoundVolume=Float(globalsoundvolume2)*0.2
GlobalMusicVolume=Float(globalMusicvolume2)*0.2
EndIf
; Randomize
For bla= 1 To MilliSecs() Mod 100
blabla=Rand(0,44)
Next
SetupCamera()
If globalmusicvolume2>0
MusicChannel=PlayMusic ("Data\music\8.ogg")
ChannelVolume MusicChannel,GlobalMusicVolume
currentmusic=8
EndIf
LevelMusicCustomVolume=100.0
LevelMusicCustomPitch=44
StartofTitleMusic=MilliSecs()
; Loading Screen
AmbientLight 0,0,0
cube=CreateCube(camera)
Global cube2=CreateCube(camera)
ScaleEntity cube2,.4,.5,.5
PositionEntity cube2,0,-1,4
EntityColor cube2,64,64,64
EntityBlend cube2,2
If portalversion=0
cubetex=myLoadTexture("load.jpg",1)
EntityTexture cube,cubetex
PositionEntity cube,0,0.1,5
RenderWorld
Else
cubetex=LoadTexture("logo.jpg",1)
EntityTexture cube,cubetex
PositionEntity cube,0,0,5
RenderWorld
Text GfxWidth*0.5,Gfxheight*25/28,"...Loading...",True
Text GfxWidth*0.5,Gfxheight*26/28,"...Please Wait...",True
EndIf
For i=0 To 255 Step 3
AmbientLight i,i,i
RenderWorld
Flip
Next
PositionEntity cube2,0.1,-1,4
RenderWorld
Flip
PreLoadModels()
PositionEntity cube2,0.9,-1,4
RenderWorld
Flip
PositionEntity cube2,1,-1,4
RenderWorld
Flip
For i=255 To 0 Step -5
AmbientLight i,i,i
RenderWorld
Flip
Next
FreeTexture cubetex
FreeEntity cube
FreeEntity cube2
SetupMenu()
SetupLight()
ResetParticles("data/graphics/particles.bmp")
ResetText("data/graphics/font.bmp")
; Start Main Menu
If playername$="" Or FileType(globaldirname$+"\player profiles\"+playername$+"\current\playerfile.wpf")<>1
; no player is availalbe - make a default (Stinky)
PlayerName$="Default"
PlayerCharacterName$="Stinky"
PlayerTextureBody=1
PlayerAcc1=1
PlayerTexAcc1=1
PlayerAcc2=0
PlayerTexAcc2=0
PlayerSizeX#=0.035
PlayerSizeY#=0.035
PlayerSizeZ#=0.035
PlayerVoice=1
PlayerPitch=1
CreateNewPlayer()
Else
loadplayer(globaldirname$+"\player profiles\"+playername$+"\current\playerfile.wpf")
EndIf
If WAEpisode=0
testfile=ReadFile(globaldirname$+"\temp\test.dat")
If testfile<>0 ;FileType(globaldirname$+"\custom\editing\")
TestAdventureFilename$=ReadString$(testfile)
CloseFile testfile
TestMode=True
HideEntity TitleMenuEntity(79)
StartAdventure(globaldirname$+"\custom\editing\current\"+TestAdventureFilename,2,0)
Else
StartMenu(11)
EndIf
Else
StartMenu(10)
EndIf
AltX\InUse=True
fpscounter=-1
fps=0
fpstime=0
TweenPeriod=1000/60;85
TweenTime=MilliSecs()-TweenPeriod
Global EndGame=False
Repeat
If HasFocus()
If justregainedfocus=1
justregainedfocus=0
If currentmusic>0 Then ResumeChannel(musicchannel)
EndIf
If currentmusic>0 ;And (gamemode<10 Or currentmenu<>10)
; music looping
If ChannelPlaying(musicchannel)=0
If currentmusic=21
MusicChannel=PlayMusic("data\models\ladder\valetfile.ogg")
Else
MusicChannel=PlayMusic("Data\music\"+currentmusic+".ogg")
EndIf
;ChannelVolume musicchannel,GlobalMusicVolume
ChannelVolume MusicChannel,GlobalMusicVolume * Float(LevelMusicCustomVolume)/100.0
ChannelPitch MusicChannel,LevelMusicCustomPitch*1000
EndIf
EndIf
Repeat
TweenElapsed=MilliSecs()-TweenTime
Until TweenElapsed>TweenPeriod
If TweenElapsed>20*TweenPeriod
TweenElapsed=20*TweenPeriod
TweenTime=MilliSecs()-TweenElapsed
EndIf
;how many 'frames' have elapsed
TweenTicks=TweenElapsed/TweenPeriod
;fractional remainder
Tween#=Float(TweenElapsed Mod TweenPeriod)/Float(TweenPeriod)
For k=1 To TweenTicks
Tweentime=Tweentime+Tweenperiod
If k=Tweenticks
CaptureWorld
EndIf
; do the game in here
If GameMode<10
UpdateGame()
;Else If GameMode=10
; UpdateAdventureTitle()
;Else If gamemode=12
; Menus
; UpdateMenu()
EndIf
If GameMode<>12
ControlLight()
LevelTimer=LevelTimer+1
AdventureTimer=AdventureTimer+1
UpdateWorld
EndIf
Next
If GameMode=10
UpdateAdventureTitle()
Else If gamemode=12
; Menus
UpdateMenu()
EndIf
If fpscounter=-1
fpstime=MilliSecs()
fpscounter=100
Else If fpscounter=0
timepassed=MilliSecs()-fpstime
fps=100000/timepassed
fpscounter=100
fpstime=MilliSecs()
Else
fpscounter=fpscounter-1
EndIf
MX=Floor(MousePickX)
MY=Floor(MousePickY)
If FPSDisplay=True;False
DisplayText("FPS: "+fps,0,46,.5,1,255,255,255)
EndIf
If DebugDisplay=True Then
DisplayText("Tile Logic: "+LevelTileLogic(Mx,MY),0,0,1,1,255,255,255)
DisplayText("Object Logic: "+objecttilelogic(mx,my),0,1,1,1,255,255,255)
DisplayText("Level Timer: "+Leveltimer,0,2,1,1,255,255,255)
EndIf
; MESSAGELINE
If MessageLineTimer>0 And MessageLineText1$<>""
ShowEntity DialogBackGroundEntity2
If MessageLineTimer<30
PositionEntity DialogBackGroundEntity2,0,.4-.4*Float(30-MessageLineTimer)/30.0,0
DisplayText(MessageLineText1$,24.5-Len(MessageLineText1$)/2.0,24-2*MessageLineTimer/30.0,1,1,255,255,0)
DisplayText(MessageLineText2$,24.5-Len(MessageLineText2$)/2.0,25-2*MessageLineTimer/30.0,1,1,255,255,0)
Else
PositionEntity DialogBackGroundEntity2,0,.4,0
DisplayText(MessageLineText1$,24.5-Len(MessageLineText1$)/2.0+.25*Sin(16*(messagelinetimer-30)),22,1,1,255,255,0)
DisplayText(MessageLineText2$,24.5-Len(MessageLineText2$)/2.0+.25*Sin(16*(messagelinetimer-30)),23,1,1,255,255,0)
EndIf
Else
HideEntity DialogBackGroundEntity2
EndIf
If MessageLineTimer>0 Then MessageLineTimer=MessageLineTimer-1
; ICON SUBTEXTS
exv#=0
exv2#=0
If widescreen And wideicons
exv=16.3
exv2=10.8
EndIf
For i=0 To 79
ex#=exv
If (i Mod 10)<2 And ex>0
ex=-ex
EndIf
If IconEntity(i)>0 And IconSize(i)>=1001
If IconSize(i)=1201
DisplayText(IconHelpText$(i),3.2+10.1*(i Mod 10)-(Len(IconHelpText$(i))-1.0)/2.0+ex,4.3+6*Floor(i/10),.5,1,255,255,255)
Else
DisplayText(IconSubText$(i),3.2+10.1*(i Mod 10)-(Len(IconSubText$(i))-1.0)/2.0+ex,3.9+6*Floor(i/10),.5,1,255,255,255)
EndIf
EndIf
Next
If GameMode=5
DisplayText("Items:",40.6-6.8*(InventorySize-3)+exv2,2.67,.75,1,255,255,0)
EndIf
If GameMode=6
DisplayText("Swap Item:",40.6-6.8*(InventorySize-3)+exv2,2.67,0.75,1,255,255,0)
EndIf
If GameMode=5 Or GameMode=6
DisplayText("Stars",49.65-4*.5+exv2,16+(InventorySize-3)*4,.75,1,255,255,0)
DisplayText("Coins",56.3-4*.5+exv2,16+(InventorySize-3)*4,.75,1,255,255,0)
DisplayText("Gems",43.5-4*.5+exv2,16+(InventorySize-3)*4,.75,1,255,255,0)
DisplayText("Score: "+PlayerScore,52.3-Len(playerscore)+exv2,20+(InventorySize-3)*4,.75,1,255,255,0)
If PlayerStars<10
k=0
Else If PlayerStars<100
k=1
Else If PlayerStars<1000
k=2
Else If PlayerStars<10000
k=3
Else
k=4
EndIf
DisplayText(Str$(PlayerStars),49.65-k*0.5+exv2,18.8+(InventorySize-3)*4,.75,1,255,255,0)
If PlayerCoins<10
k=0
Else If PlayerCoins<100
k=1
Else If PlayerCoins<1000
k=2
Else If PlayerCoins<10000
k=3
Else
k=4
EndIf
DisplayText(Str$(PlayerCoins),56.3-k*0.5+exv2,18.8+(InventorySize-3)*4,.75,1,255,255,0)
If PlayerGems<10
k=0
Else If PlayerGems<100
k=1
Else If PlayerGems<1000
k=2
Else If PlayerGems<10000
k=3
Else
k=4
EndIf
DisplayText(Str$(PlayerGems),43-k*0.5+exv2,18.8+(InventorySize-3)*4,.75,1,255,255,0)
EndIf
; TEXT DIALOG
If GameMode=8
DisplayDialog()
EndIf
If KeyDown(63) Then FpsDisplay=True
; If MidnightVault=0 And KeyDown(6)
; MidnightVault=1
; MidnightVaultTimer=MilliSecs()
; Else If MidnightVault=1 And KeyDown(9)
; MidnightVault=2
; Else If MidnightVault=2 And KeyDown(3)
; MidnightVault=3
; Else If MidnightVault=3 And KeyDown(6)
; ; MidnightVault=4
; MessageLineText1$="Sorry. I don't have the"
; MessageLineText2$="key to the Vault ;-)"
; MessageLineTimer=100
; Else If KeyDown(2) Or KeyDown(4) Or KeyDown(5) Or KeyDown(8) Or KeyDown(10)
; MidnightVault=0
; EndIf
If KeyDown(48) And (KeyDown(29) Or KeyDown(157))
WallBlinking=True
MessageLineText1$="Wall-Blinking Activated"
MessageLineText2$="(use at your own risk)"
MessageLineTimer=100
EndIf
If MidnightVaultTimer>0 And MidnightVault<5
If MilliSecs()-MidnightVaultTimer>1500
MidnightVault=0
MidnightVaultTimer=0
EndIf
EndIf
;If KeyDown(29)
; TweenPeriod=1000
;E;lse
; tweenperiod=1000/60
; EndIf
If KeyDown(1)
If EscPressed=False
EscPressed=True
; select via game mode
If gamemode<10
; in game
If delaycommand=7 Or delaycommand=8
Else If CurrentCharm=3 Or CurrentCharm=4
; turn off spy eye\map
ShowEntity LevelCursor
CurrentCharm=0
TurnOnIcons()
DeleteIcon(1)
MouseGameMode=-2
AutoGlowGem()
Else If LevelTimer<1000001000 Or LevelTimer>=1000001500
; not in adventure won animation
PlaySoundFX(131,-1,-1)
HideEntity LevelCursor
StartMenu(0)
Else
; in adventure won animation
LevelTimer=1000001498
EndIf
Else If gamemode=10
; in adventure start animation
LevelTimer=1000000000
Else If gamemode=12
; in menu
Select currentmenu
Case 0
; in game
endmenu()
startmenu(3)
Case 1,2,4,5,6
endmenu()
Case 3
; in game exit are you sure
EndMenu()
endLevel()
endadventure()
StartMenu(11)
Case 11
; main menu
endmenu()
startmenu(19)
Case 16,18,26 ;,14,15 - don't escape from 14/15 since new profile name already entered
endmenu()
startmenu(11)
Case 20
endmenu()
PlayerName$=OldPlayerName$
PlayerCharacterName$=OldPlayerCharacterName$
startmenu(11)
Case 12
If OldPlayerName$<>"" And OldPlayerCharacterName$<>""
PlayerName$=OldPlayerName$
PlayerCharacterName$=OldPlayerCharacterName$
endmenu()
startmenu(11)
EndIf
Case 13
If OldPlayerName$<>"" And OldPlayerCharacterName$<>""
PlayerName$=OldPlayerName$
PlayerCharacterName$=OldPlayerCharacterName$
endmenu()
startmenu(11)
EndIf
Case 14
If OldPlayerCharacterName$=".." ; can only exit if from within options menu
PlayerCharacterName$=OldPlayerCharacterName2$
OldPlayerCharacterName$=""
endmenu()
startmenu(11)
EndIf
Case 15
endmenu()
startmenu(14)
Case 17
endmenu()
startmenu(12)
Case 19
End
Case 100
endcustomselectmenu()
startmenu(11)
MouseGameMode=2
Case 101
CurrentMenu=100
CustomLevelListSelected=-1
End Select
EndIf
EndIf
Else
EscPressed=False
EndIf
If GfxWindowed=2 ; remove mousecursor if at endge of screen in windowed mode
If MouseX()<10 Or MouseY()<10 Or MouseX()>GfxWidth-10 Or MouseY()>GfxHeight-10
HideEntity MouseCursor
Else If MouseCursorVisible=True
ShowEntity MouseCursor
EndIf
EndIf
RenderGame()
Else
; out of focus
If currentmusic>0
PauseChannel musicchannel
EndIf
justregainedfocus=1
Repeat
Delay 200
Until HasFocus()
TweenTime=MilliSecs()
EndIf
Until endgame=True
; clear memory
ClearWorld()
EndGraphics()
; play exit sound
SeedRnd MilliSecs()
byesnd=Rand(1,2)
If byesnd=1 mysndfile$ = "weebye" ;71
If byesnd=2 mysndfile$ = "weethanks" ;72
byesndfx = myLoadSound("Data\Sound\" + mysndfile$+".wav")
SoundVolume byesndfx,GlobalSoundVolume
byesndchn=PlaySound(byesndfx)
While ChannelPlaying(byesndchn)
Wend
End
Function UpdateGame()
ResetSounds()
Mouse1=False
Mouse2=False
If MouseDown(1)=True Or MouseHit(1)>0
Mouse1=True
EndIf
If MouseDown(2)=True Or MouseHit(2)>0
Mouse2=True
EndIf
;widescreen
If widescreen
PositionEntity MouseCursor,-13.28+26.625*Float(MouseX())/Float(GFXWidth),7.5-15*Float(MouseY())/Float(GfxHeight),20
Else
PositionEntity MouseCursor,-10+20*Float(MouseX())/Float(GFXWidth),7.5-15*Float(MouseY())/Float(GfxHeight),20
EndIf
If GameMode=0
ShowEntity LevelCursor
EndIf
CameraControls()
ControlCamera()
ControlIcons()
ControlDialog()
ControlObjects()
ControlParticles()
; Check End-of-Adventure
If LevelTimer<1000001000 Or LevelTimer>=1000002000
Flag=False
Select AdventureGoal
Case 0
; no goal
Case 1
If NofWeeStinkersInAdventure=0
Flag=True
EndIf
Case 2
If NofScrittersInAdventure=0
Flag=True
EndIf
Case 3
If NofGemsInAdventure=0
Flag=True
EndIf
Case 4
If NofBricksInAdventure=0
Flag=True
EndIf
Case 5
If NofFireFlowersInAdventure=0
Flag=True
EndIf
Case 6
; race - no goal
Case 7
If NofCrabsInAdventure=0
Flag=True
EndIf
Case 8
If NofBabyBoomersInAdventure=0
Flag=True
EndIf
Case 9