From 069402c4ec3750c61d1eee5f99618890c0e1645f Mon Sep 17 00:00:00 2001 From: Yann Lebrun Date: Thu, 17 Jul 2025 20:36:20 +0200 Subject: [PATCH] Initial commit --- AltonFont.dat | Bin 0 -> 1442 bytes AltonFont2.dat | Bin 0 -> 1442 bytes BitmapText.pbi | 368 +++++++ Bonus.pbi | 371 +++++++ Cinematic.pbi | 126 +++ Cinematic_Old.pbi | 128 +++ Create Package.pb | 91 ++ Database.pbi | 327 ++++++ Datas/LoopzFont.dat | Bin 0 -> 1442 bytes Datas/MonoFont.dat | Bin 0 -> 1442 bytes EarthQuake.pbi | 114 +++ Easing.pbi | 753 ++++++++++++++ Fontcreator.pb | 95 ++ GUI.pbi | 79 ++ Game.pbi | 1824 ++++++++++++++++++++++++++++++++++ GameStructure.pbi | 478 +++++++++ Linux_Screen3DMousePatch.pbi | 260 +++++ LoopzFont.dat | Bin 0 -> 1442 bytes Main.pb | 450 +++++++++ Menu.pbi | 178 ++++ Menu_old.pbi | 161 +++ MonoFont.dat | Bin 0 -> 1442 bytes MoveEngine.pbi | 181 ++++ MyFont.dat | Bin 0 -> 1442 bytes Network.pbi | 56 ++ NewBitmap.pbi | 29 + Pack.dat | Bin 0 -> 3748718 bytes Package.pb | 123 +++ Screen.pbi | 155 +++ Shape.pbi | 597 +++++++++++ Sound.pbi | 76 ++ Sprite.pbi | 143 +++ SpritesObj.pbi | 259 +++++ ThyBitmapFontCreator.pb | 166 ++++ ThyBitmapFontCreator2.pb | 123 +++ score.pbi | 4 + test.pb | 134 +++ 37 files changed, 7849 insertions(+) create mode 100644 AltonFont.dat create mode 100644 AltonFont2.dat create mode 100644 BitmapText.pbi create mode 100644 Bonus.pbi create mode 100644 Cinematic.pbi create mode 100644 Cinematic_Old.pbi create mode 100644 Create Package.pb create mode 100644 Database.pbi create mode 100644 Datas/LoopzFont.dat create mode 100644 Datas/MonoFont.dat create mode 100644 EarthQuake.pbi create mode 100644 Easing.pbi create mode 100644 Fontcreator.pb create mode 100644 GUI.pbi create mode 100644 Game.pbi create mode 100644 GameStructure.pbi create mode 100644 Linux_Screen3DMousePatch.pbi create mode 100644 LoopzFont.dat create mode 100644 Main.pb create mode 100644 Menu.pbi create mode 100644 Menu_old.pbi create mode 100644 MonoFont.dat create mode 100644 MoveEngine.pbi create mode 100644 MyFont.dat create mode 100644 Network.pbi create mode 100644 NewBitmap.pbi create mode 100644 Pack.dat create mode 100644 Package.pb create mode 100644 Screen.pbi create mode 100644 Shape.pbi create mode 100644 Sound.pbi create mode 100644 Sprite.pbi create mode 100644 SpritesObj.pbi create mode 100644 ThyBitmapFontCreator.pb create mode 100644 ThyBitmapFontCreator2.pb create mode 100644 score.pbi create mode 100644 test.pb diff --git a/AltonFont.dat b/AltonFont.dat new file mode 100644 index 0000000000000000000000000000000000000000..72d55b1ce7e1e5ece97d061de846eef52c88c4ae GIT binary patch literal 1442 zcmZ9JF-Tis6op@FV@Hv8a7+nZ96}+`IutaBAc&>lCZ%R{&>_0Cg;IlNQWwpjgIG!^ z)KbK;bop_xtE=ehq)>=kaqt{+4!+zU?z{QkIsbk4-V{G&I!}=kf|=(vA|c))cqS1E zv4h~5M{3<;{ zZ_)#Fi`M+R=0kdr^~dxueL-veU0U9*c^|x$!^oQ}vH)-uR`pNSr zX7q!+`n#bE5wZSz^RxM#*7tyZ^Z9-)A50r@>v@Q|alUioeCMv2@hs%E-Zjf3myd7L zdjET7{2!oR=K=c#tNxtU|Ian8ejd$l=5KSK*8T+(zB$c@2&+H5lRRIgwcdGJ=LzQp J^~$fC{{ZAFI(`5E literal 0 HcmV?d00001 diff --git a/BitmapText.pbi b/BitmapText.pbi new file mode 100644 index 0000000..c6517f1 --- /dev/null +++ b/BitmapText.pbi @@ -0,0 +1,368 @@ +;-NewBitmap + +Structure myFontData + x.l + y.l + Width.l + Height.l +EndStructure + +Structure BitmapFont + SpriteId.i + FirstClipSpriteId.l + AsciiStart.c + AsciiEnd.c + Array Tab.l(10) + Array FontData.myFontData(1) +EndStructure + +Global NewList BitmapFont.BitmapFont() + +Procedure.i CatchBitmapFont(FirstClipSpriteId.l,FontFileName.S) + Protected z.l + Protected *Mem,*Dat + *Mem=AddElement(BitmapFont()) + BitmapFont()\FirstClipSpriteId=FirstClipSpriteId + + *Dat=ReadDataPackage("Datas.pck",FontFileName+".dat") + BitmapFont()\AsciiStart=PeekB(*Dat) + BitmapFont()\AsciiEnd=PeekB(*Dat+1) + ;Debug BitmapFont()\AsciiStart + ;Debug BitmapFont()\AsciiEnd + ;ShowMemoryViewer(*Dat,MemorySize(*Dat)) + ;End + ReDim BitmapFont()\FontData(BitmapFont()\AsciiEnd-BitmapFont()\AsciiStart) + CopyMemory(*Dat+2,@BitmapFont()\FontData(),SizeOf(myFontData)*ArraySize(BitmapFont()\FontData())) + FreeMemory(*Dat) +; If OpenFile(0,"Datas/"+FileName+".dat") +; BitmapFont()\AsciiStart=ReadCharacter(0,#PB_Ascii) +; BitmapFont()\AsciiEnd=ReadCharacter(0,#PB_Ascii) +; ReDim BitmapFont()\FontData(BitmapFont()\AsciiEnd-BitmapFont()\AsciiStart) +; ReadData(0,@BitmapFont()\FontData(),SizeOf(myFontData)*ArraySize(BitmapFont()\FontData())) +; CloseFile(0) +; EndIf + BitmapFont()\SpriteId=CatchSpriteFromPackage(#PB_Any,FontFileName+".png");LoadSprite(#PB_Any,"Datas/"+FileName+".png",#PB_Sprite_AlphaBlending) + If IsSprite(BitmapFont()\SpriteId) + For z=0 To ArraySize(BitmapFont()\FontData()) + RecordSprite(FirstClipSpriteId+z,BitmapFont()\SpriteId,BitmapFont()\FontData(z)\x,BitmapFont()\FontData(z)\y,BitmapFont()\FontData(z)\Width,BitmapFont()\FontData(z)\Height,BitmapFont()\FontData(z)\Width/BitmapFont()\FontData(z)\Height, 1) + Next +Else + Debug "error load font" + End + EndIf + ProcedureReturn *Mem +EndProcedure + + +Procedure.i LoadBitmapFont(FirstClipSpriteId.l,FileName.s="MonoFont") + Protected z.l + Protected *Mem + *Mem=AddElement(BitmapFont()) + BitmapFont()\FirstClipSpriteId=FirstClipSpriteId + If OpenFile(0,"Datas/"+FileName+".dat") + BitmapFont()\AsciiStart=ReadCharacter(0,#PB_Ascii) + BitmapFont()\AsciiEnd=ReadCharacter(0,#PB_Ascii) + ReDim BitmapFont()\FontData(BitmapFont()\AsciiEnd-BitmapFont()\AsciiStart) + ReadData(0,@BitmapFont()\FontData(),SizeOf(myFontData)*ArraySize(BitmapFont()\FontData())) + CloseFile(0) + EndIf + Debug FileName+".png" + BitmapFont()\SpriteId=LoadSprite(#PB_Any,"Datas/"+FileName+".png",#PB_Sprite_AlphaBlending) + If IsSprite(BitmapFont()\SpriteId) + For z=0 To ArraySize(BitmapFont()\FontData()) + RecordSprite(FirstClipSpriteId+z,BitmapFont()\SpriteId,BitmapFont()\FontData(z)\x,BitmapFont()\FontData(z)\y,BitmapFont()\FontData(z)\Width,BitmapFont()\FontData(z)\Height,BitmapFont()\FontData(z)\Width/BitmapFont()\FontData(z)\Height, 1) + Next +Else + Debug "error load font" + End + EndIf + ProcedureReturn *Mem +EndProcedure + +Procedure TextBitmapWidth(string.s) + Protected l.l,c.l,n.l,width.l,size.l=0 + Protected tabIndex.l=0 + For l=0 To Len(String)-1 + c=Asc(Mid(String,l+1,1));-BitmapFont()\AsciiStart + width=0 + If c=9 ; TAB + Width=BitmapFont()\Tab(tabIndex) -Size + tabIndex=tabIndex+1 + ElseIf c=32; Espace and _ + Width=GUI\HalfBlockSize + Else + c=c-BitmapFont()\AsciiStart + If c>=1 And c-1 And FontID=1 Or c0 + Protected RealLineSpacing=Titles\LineSpacing*GUI\BlockSize + Protected LineHeight.f=GUI\BlockSize+RealLineSpacing + + Titles\ScrollY=Titles\ScrollY+ ScreenHeight()*(ElapsedMilliseconds()-Titles\StartTime)/Titles\Speed ;6000 + If Titles\ScrollY>ScreenHeight()+ ListSize(Titles\Title())* LineHeight + If Titles\Event>-1: + PostEventGUI(Titles\Event) + EndIf + Titles\ScrollY=0 + EndIf + ForEach Titles\Title() + DrawingBitmapFont(Titles\Title()\FondId) + Protected.l Y=ScreenHeight() + ListIndex(Titles\Title()) * LineHeight - Titles\ScrollY + If Y>-LineHeight And YMessage()\StartTime + Message()\MessStep=Message()\MessStep+1 + Message()\StartTime=0 + EndIf + Case 1; Display + If Message()\StartTime=0:Message()\StartTime=ElapsedMilliseconds()+Message()\Duration:EndIf + If ElapsedMilliseconds()>Message()\StartTime + Message()\MessStep=Message()\MessStep+1 + Message()\StartTime=0 + EndIf + Fade=255 + Case 2; + If Message()\StartTime=0:Message()\StartTime=ElapsedMilliseconds()+Message()\FadeDuration:EndIf + Fade=Int((Message()\StartTime-ElapsedMilliseconds())*255/Message()\FadeDuration) + If ElapsedMilliseconds()>Message()\StartTime + Message()\MessStep=Message()\MessStep+1 + Message()\StartTime=0 + EndIf + Case 3 + EndSelect + DrawingBitmapFont(Message()\Font) + Protected Width.l=TextBitmapWidth(Message()\String) + DrawBitmapText((ScreenWidth()-Width)/2,GUI\BenchY+GUI\BenchHeight,Message()\String,Fade) + If Message()\MessStep=3 + DeleteElement(Message()) + EndIf + EndIf +EndProcedure +; IDE Options = PureBasic 6.11 LTS (Windows - x64) +; CursorPosition = 255 +; FirstLine = 255 +; Folding = --- +; EnableXP \ No newline at end of file diff --git a/Bonus.pbi b/Bonus.pbi new file mode 100644 index 0000000..3b696ff --- /dev/null +++ b/Bonus.pbi @@ -0,0 +1,371 @@ +; Moved to GameStructure +; Enumeration BonusType +; #Bonus_Health ; Add Health +; #Bonus_Time ; Slowest Time +; #Bonus_EarthQuake ; Check Bench and pieces Fall +; #Bonus_Dead ; All points X2 +; #Bonus_X2 ; All points X4 +; #Bonus_JewelBlue ; +; #Bonus_JewelRed ; +; #Bonus_Eye +; #Bonus_End +; EndEnumeration + +Structure DisplayedBonus + Type.l ;see BonusType Enumeration + X.l + Y.l + State.l + Alpha.l + StartTime.l + Duration.l +EndStructure + +Structure Bonus + List DisplayedBonus.DisplayedBonus() + Dead_StartTimer.q + EyeEnable.b + HammerEnable.b + BonusScrollDisplayed.b + Hammer_StartTime.q + Random_StartTime.q + Random_Duration.l + RemoveEnable.b + Remove_StartTime.q + X2Enable.b + FreezeEnable.b + FreezeStartTime.q + FreezeTimer.l + FreezeAlpha.l +EndStructure + + +Global Bonus.Bonus + +Procedure NewBonus(BonusType.l,Bx.l=-1,By.l=-1) + Protected TmpX.l,TmpY.l + Protected Authorization.b=#False + Protected Count.l=0 + Protected Quit.b=#False + Debug "_____NewBonus()____" + If BonusType<>#Bonus_X2 Or (BonusType=#Bonus_X2 And Bonus\X2Enable<3) ;No Over x8 + + If Bx=-1 + Protected BonusCase.l + Repeat + Count=Count+1 + BonusCase.l=RandUniq() + TmpX=BonusCase%(#MaxTableWidth+1) + TmpY=BonusCase/(#MaxTableWidth+1) + Debug "Test New Bonus "+Str(TmpX)+","+Str(TmpY)+" BonusType="+Str(BonusType) + If BonusType=#Bonus_Dead:Debug "Add Dead Bonus":EndIf + If Game\GameTable(TmpX,TmpY)\BonusOnThisCase=#False + If (TmpX=Game\BlockMouseX And TmpY=Game\BlockMouseY) + Debug "Bonus Under Mouse " + Quit=#True + Else + Authorization=#True + Quit=#True + EndIf + EndIf + + If Count=4 And Game\GameTable(TmpX,TmpY)\BonusOnThisCase=#True + Quit=#True + EndIf + + Until Quit=#True + Else + If Bx=Game\BlockMouseX And By=Game\BlockMouseY + Debug "Bonus Under Mouse Bis" + Else + Authorization=#True + TmpX=Bx + TmpY=By + + EndIf + EndIf + + If Authorization=#True And Game\GameTable(TmpX,TmpY)\BonusOnThisCase=#False + AddElement(Bonus\DisplayedBonus()) + Bonus\DisplayedBonus()\Type=BonusType + Bonus\DisplayedBonus()\X=TmpX + Bonus\DisplayedBonus()\Y=TmpY + Bonus\DisplayedBonus()\StartTime=ElapsedMilliseconds() + Game\GameTable(TmpX,TmpY)\BonusOnThisCase=#True + + Select BonusType + Case #Bonus_Health + Bonus\DisplayedBonus()\Duration=4000 + Case #Bonus_Time ; Slowest Time + Bonus\DisplayedBonus()\Duration=Random(4000,2500) + Case #Bonus_EarthQuake ; Check Bench and pieces Fall + Bonus\DisplayedBonus()\Duration=4000 + Case #Bonus_Dead ; Dead + Bonus\DisplayedBonus()\Duration=Game\Difficulty(Game\ScoreData\Difficulty)\DeadBonusDuration + Bonus\Dead_StartTimer=ElapsedMilliseconds() + Case #Bonus_X2 ; All points X2 + Bonus\DisplayedBonus()\Duration=4000 + Case #Bonus_Eye + Bonus\DisplayedBonus()\Duration=4000 + If Game\ScoreData\Difficulty<2 + Bonus\DisplayedBonus()\Type=#Bonus_Time + EndIf + Case #Bonus_JewelBlue,#Bonus_JewelRed ; Jewel + Bonus\DisplayedBonus()\Duration=Random(6000,3000) + Case #Bonus_Gravity + Bonus\DisplayedBonus()\Duration=4000 + Bonus\BonusScrollDisplayed=#True + Case #Bonus_Freeze + Bonus\DisplayedBonus()\Duration=4000 + Default + Bonus\DisplayedBonus()\Duration=4000 + EndSelect + PlaySound(#Snd_Woosh) + Else + Debug "Lost Bonus No empty Case" + EndIf + EndIf +EndProcedure + +Procedure NewBonus_old(BonusType.l,Bx.l=-1,By.l=-1) + AddElement(Bonus\DisplayedBonus()) + Bonus\DisplayedBonus()\Type=BonusType + + ;Loop to never put Bonus on Mouse Cursor + If Bx=-1 + Repeat + Protected BonusCase.l + BonusCase.l=RandUniq(); RandUniq() function is GameStructure.pbi + Bonus\DisplayedBonus()\X=BonusCase%(#MaxTableWidth+1) + Bonus\DisplayedBonus()\Y=BonusCase/(#MaxTableWidth+1) + Debug "New Bonus "+Str(Bonus\DisplayedBonus()\X)+","+Str(Bonus\DisplayedBonus()\Y) + Until (Bonus\DisplayedBonus()\X>Game\BlockMouseX+1 Or Bonus\DisplayedBonus()\XGame\BlockMouseY+1 Or Bonus\DisplayedBonus()\YBonus\DisplayedBonus()\Duration-500 + Bonus\DisplayedBonus()\Alpha=Int((Bonus\DisplayedBonus()\Duration-During)/2) + Else + Bonus\DisplayedBonus()\Alpha=255 + EndIf + If During>Bonus\DisplayedBonus()\Duration + If Bonus\DisplayedBonus()\Type=#Bonus_Gravity + Bonus\BonusScrollDisplayed=#False + EndIf + Game\GameTable(Bonus\DisplayedBonus()\X,Bonus\DisplayedBonus()\Y)\BonusOnThisCase=#False + DeleteElement(Bonus\DisplayedBonus()) + Else + DisplayClipSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,TmpX,TmpY,Bonus\DisplayedBonus()\Alpha) + ;DrawBitmapText(TmpX,TmpY,Str(Bonus\DisplayedBonus()\Alpha)) ; Display Tansparency on Bonus + EndIf + Next +EndProcedure + +; Procedure ScrollLeft() +; Protected Bx.l,By.l +; For By=0 To #MaxTableHeight +; Protected EmptyCase.l=-1 +; For Bx=0 To #MaxTableWidth +; If Game\GameTable(Bx,By)\Sprite>0 +; If EmptyCase>-1 +; Game\GameTable(EmptyCase,By)\Sprite=Game\GameTable(Bx,By)\Sprite +; Game\GameTable(EmptyCase,By)\Selected=Game\GameTable(Bx,By)\Selected +; Game\GameTable(Bx,By)\Sprite=0 +; Game\GameTable(Bx,By)\Selected=0 +; EmptyCase=EmptyCase+1 +; EndIf +; ElseIf Game\GameTable(Bx,By)\Sprite=0 +; If EmptyCase=-1:EmptyCase=Bx:EndIf +; EndIf +; Next +; Next +; EndProcedure + + +Procedure ScrollDown() + Protected Bx.l,By.l + For Bx=0 To #MaxTableWidth + Protected EmptyCase.l=#MaxTableHeight+1 + For By=#MaxTableHeight To 0 Step -1 + If Game\GameTable(Bx,By)\Sprite=0 + If EmptyCase=#MaxTableHeight+1:EmptyCase=By:EndIf + Else + If EmptyCase<#MaxTableHeight+1 + Game\GameTable(Bx,EmptyCase)\Sprite=Game\GameTable(Bx,By)\Sprite + Game\GameTable(By,EmptyCase)\Selected=Game\GameTable(Bx,By)\Selected + Game\GameTable(Bx,By)\Sprite=0 + Game\GameTable(Bx,By)\Selected=0 + EmptyCase=EmptyCase-1 + EndIf + EndIf + Next + Next +EndProcedure + + +Procedure TakeBonus(Bx.l,By.l) + ;-Mouse Take Bonus + If ListSize(Bonus\DisplayedBonus())>0 + + ForEach Bonus\DisplayedBonus() + + If Bx=Bonus\DisplayedBonus()\X And By=Bonus\DisplayedBonus()\Y And Bonus\DisplayedBonus()\Alpha>90 + Debug "Bonus "+Str(Bx)+","+Str(By)+" Type="+Str(Bonus\DisplayedBonus()\Type) + Game\GameTable(BX,BY)\BonusOnThisCase=#False + Protected *Obj_Sprite.SpriteData + + ;Param\game\Stats\NbBonus(Bonus\DisplayedBonus()\Type)=Param\game\Stats\NbBonus(Bonus\DisplayedBonus()\Type)+1 + Select Bonus\DisplayedBonus()\Type + Case #Bonus_Health ; Add Health + ;Game\Life=Game\Life+1 ;Moved to Event in Game.pbi Gamemode() + PlaySound(#Snd_GetBonus) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,19,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,0,#Easing_BackEaseIn,#EventGui_AddHealth,@*Obj_Sprite\AutoDestroy) + Case #Bonus_Time ; Slowest Time + PlaySound(#Snd_GetBonus) + + Game\Timer=Game\Timer+400 + Game\NextTime=ElapsedMilliseconds()+Game\Timer + + Case #Bonus_EarthQuake ; Check Bench and pieces Fall + StartEarthQuake() ; Do Earth Quake + Case #Bonus_Dead ; All points X2 + PlaySound(#Snd_DeadBonus) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx+0.5,By+0.5,1,1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Size,#PB_Float,0,1000,1,100,#Easing_Linear,#EventGui_Dead,@*Obj_Sprite\AutoDestroy) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,Bx+1.5,GUI\ScreenWidth/2,#Easing_Linear) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,By+1.5,GUI\ScreenHeight/2,#Easing_Linear) + NewMessage("DEAD",0) + Debug "DEAD"+Str(ListSize(Bonus\DisplayedBonus())) + Game\WaitTimer=ElapsedMilliseconds()+1000 + Case #Bonus_X2 ; All points X4 + If Bonus\X2Enable<3 ;No Over x8 + PlaySound(#Snd_GetBonus2) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + Debug "X2" + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,5,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,0,#Easing_BackEaseIn,#EventGui_AddX2,@*Obj_Sprite\AutoDestroy) + Debug "___" + EndIf + Case #Bonus_JewelBlue + ;Game\Bonus_JewelBlue=Game\Bonus_JewelBlue+1 ;Moved to Event in Game.pbi Gamemode() + PlaySound(#Snd_GetJewel) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,8,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,0,#Easing_BackEaseIn,#EventGui_AddJewelBlue,@*Obj_Sprite\AutoDestroy) + Case #Bonus_JewelRed ; Jewel + ;Game\Bonus_JewelRed=Game\Bonus_JewelRed+1 ;Moved to Event in Game.pbi Gamemode() + PlaySound(#Snd_GetJewel) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,11,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,0,#Easing_BackEaseIn,#EventGui_AddJewelRed,@*Obj_Sprite\AutoDestroy) + Case #Bonus_JewelGreen + ;Game\Bonus_JewelBlue=Game\Bonus_JewelBlue+1 ;Moved to Event in Game.pbi Gamemode() + PlaySound(#Snd_GetJewel) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,14,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,0,#Easing_BackEaseIn,#EventGui_AddJewelGreen,@*Obj_Sprite\AutoDestroy) + Case #Bonus_Eye + PlaySound(#Snd_GetBonus2) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,14.5,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,8,#Easing_BackEaseIn,#EventGui_EnableEye,@*Obj_Sprite\AutoDestroy) + Case #Bonus_Gravity + ScrollDown() + ;ScrollLeft() + PlaySound(#Snd_Collapse) + Case #Bonus_Hammer + PlaySound(#Snd_GetBonus2) + + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,3,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,0,#Easing_BackEaseIn,#EventGui_EnableHammer,@*Obj_Sprite\AutoDestroy) + Game\WaitTimer=ElapsedMilliseconds()+1000 + Case #Bonus_Remove + PlaySound(#Snd_GetBonus2) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,3,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,0,#Easing_BackEaseIn,#EventGui_EnableRemover,@*Obj_Sprite\AutoDestroy) + Game\WaitTimer=ElapsedMilliseconds()+1000 + + Case #Bonus_Freeze + PlaySound(#Snd_GetBonus2) + *Obj_Sprite=NewSprite(#Spr_Health+Bonus\DisplayedBonus()\Type,Bx,By,1,1,255,1,#Spr_Depth_Front,9) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,BX+1,10,#Easing_BackEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,BY+1,9,#Easing_BackEaseIn,#EventGui_EnableFreeze,@*Obj_Sprite\AutoDestroy) + Game\WaitTimer=ElapsedMilliseconds()+1000 + EndSelect + DeleteElement(Bonus\DisplayedBonus()) + EndIf + Next + + EndIf +EndProcedure + + +; IDE Options = PureBasic 6.11 LTS (Windows - x64) +; CursorPosition = 129 +; FirstLine = 57 +; Folding = - +; EnableXP +; DPIAware \ No newline at end of file diff --git a/Cinematic.pbi b/Cinematic.pbi new file mode 100644 index 0000000..e1c156a --- /dev/null +++ b/Cinematic.pbi @@ -0,0 +1,126 @@ +Structure Cinestep + Value.SpriteObj + Duration.l + EasingH.l + EasingV.l +EndStructure + +Structure Cinematic + *Value.SpriteObj + StartTime.q + Duration.l + StepIndex.l + Loob.b + EventGUI.l + List Cinestep.Cinestep() +EndStructure + +Global NewList Cinematic.Cinematic() + +Procedure AddCinematicStep(*C.Cinematic,Duration,EasingV.l,EasingH.l) + Protected *Step.CineStep + *Step=AddElement(*C\Cinestep()) + *Step\Duration=Duration + *Step\EasingH=EasingH + *Step\EasingV=EasingV + ProcedureReturn *Step +EndProcedure + +Procedure SetCinematicStepValue(*Step.Cinestep,X.f,Y.f,Width.f=-1,Height.f=-1,Opacity=255,Size.f=1) + *Step\Value\X=X + *Step\Value\Y=Y + *Step\Value\Width=Width + *Step\Value\Height=Height + *Step\Value\Opacity=Opacity + *Step\Value\Size=Size +EndProcedure + +Procedure NewCinematic(*SpriteObj,EventGUI=-1) + Protected *Cine.Cinematic + *Cine=AddElement(Cinematic()) + *Cine\Value=*SpriteObj + *Cine\StartTime=-1 ; No Started + *Cine\StepIndex=-1 + *Cine\EventGUI=EventGUI + *Cine\Duration=0 + ProcedureReturn *Cine +EndProcedure + +Procedure RenderCinematics() + Protected ElapsedTime.q + Protected *Start.Cinestep + Protected *Target.Cinestep + ForEach Cinematic() + If Cinematic()\StartTime<>-1 + ElapsedTime=ElapsedMilliseconds()-Cinematic()\StartTime + + + If ElapsedTime>Cinematic()\Duration + Cinematic()\StepIndex=Cinematic()\StepIndex+1 + Cinematic()\StartTime=ElapsedMilliseconds() + If Cinematic()\StepIndex>ListSize(Cinematic()\CineStep())-2 + Debug "End" + If Cinematic()\EventGUI>0 + Debug "PostEventGUI="+Str(Cinematic()\EventGUI) + PostEventGUI(Cinematic()\EventGUI) + EndIf + If Cinematic()\Loob=#True + Cinematic()\StepIndex=0 + Else + Cinematic()\StartTime=-1 + Cinematic()\StepIndex=-1 + EndIf + EndIf + EndIf + If ListSize(Cinematic()\CineStep())>0 And Cinematic()\StepIndex>=0 And Cinematic()\StepIndex-1 + Cinematic()\Value\X=GetEasingPosValue(*Start\Value\X, *Target\Value\X,Cinematic()\StartTime, *Target\Duration, *Target\EasingH) + Cinematic()\Value\Y=GetEasingPosValue(*Start\Value\Y, *Target\Value\Y,Cinematic()\StartTime, *Target\Duration, *Target\EasingV) + If *Target\Value\Width<>-1 + Cinematic()\Value\Width=GetEasingPosValue(*Start\Value\Width, *Target\Value\Width,Cinematic()\StartTime, *Target\Duration, *Target\EasingH) + EndIf + If *Target\Value\Height<>-1 + Cinematic()\Value\Height=GetEasingPosValue(*Start\Value\Height, *Target\Value\Height,Cinematic()\StartTime, *Target\Duration, *Target\EasingV) + EndIf + If *Target\Value\Opacity<>-1 + Cinematic()\Value\Opacity=GetEasingPosValue(*Start\Value\Opacity, *Target\Value\Opacity,Cinematic()\StartTime, *Target\Duration, 0) + EndIf + If *Target\Value\Size<>-1 + Cinematic()\Value\Size=GetEasingPosValue(*Start\Value\Size, *Target\Value\Size,Cinematic()\StartTime, *Target\Duration, 0) + EndIf + EndIf + EndIf + EndIf + Next +EndProcedure + +Procedure StartCinematic(*C.Cinematic=0) + If *C=0 + ForEach Cinematic() + Cinematic()\StartTime=ElapsedMilliseconds() + Cinematic()\StepIndex=-1 + Next + Else + *C\StartTime=ElapsedMilliseconds() + *C\StepIndex=-1 + EndIf +EndProcedure + +Procedure FreeAllCinematics() + ForEach Cinematic() + ClearList(Cinematic()\Cinestep()) + Next + ClearList(Cinematic()) +EndProcedure +; IDE Options = PureBasic 6.00 Beta 5 (Windows - x64) +; CursorPosition = 74 +; FirstLine = 37 +; Folding = -- +; EnableXP \ No newline at end of file diff --git a/Cinematic_Old.pbi b/Cinematic_Old.pbi new file mode 100644 index 0000000..d5e8729 --- /dev/null +++ b/Cinematic_Old.pbi @@ -0,0 +1,128 @@ +;- Cinematic +Enumeration + #CV_X + #CV_Y + #CV_Width + #CV_Height + #CV_Opacity + #CV_Size + #CV_End +EndEnumeration + +Structure CineValue + Value.f + Easing.l +EndStructure + +Structure CineStep + Array CineValue.CineValue(#CV_End-1) + Duration.l +EndStructure + +Structure Cinematic + StartTime.q + StepIndex.l + Duration.l + Array *TargetValue.Long(#CV_End-1) + Loop.b + List CineStep.CineStep() +EndStructure + +Global NewList Cinematic.Cinematic() + +Procedure.i NewCinematic() + Protected *c.Cinematic=AddElement(Cinematic()) + *c\StartTime=-1 + ProcedureReturn *c +EndProcedure + +Procedure StartCinematic(*C.Cinematic) + *C\StartTime=ElapsedMilliseconds() + Cinematic()\StepIndex=-1 + Cinematic()\Duration=-1 +EndProcedure + +Procedure AddCinematicStep(*c.Cinematic,Duration.l) + Protected *Step.CineStep=AddElement(*c\CineStep()) + *Step\Duration=Duration + Protected n.l + For n=0 To #CV_End-1 + *Step\CineValue(n)\Value=-1 + Next + ProcedureReturn *Step +EndProcedure + +Procedure FreeCinematicStep(*c.Cinematic) + ClearList(*c\CineStep()) +EndProcedure + +Procedure AddCinematicValue(*c.Cinematic,ValueIndex.l,*Value) + *c\TargetValue(ValueIndex)=*Value +EndProcedure + +Procedure AddCinematicStepValue(*Step.CineStep,ValueIndex.l,Value.f,Easing.l) + *Step\CineValue(ValueIndex)\Value=Value + *Step\CineValue(ValueIndex)\Easing=Easing +EndProcedure + + +Procedure RenderCinematics() + Protected *Start.CineStep + Protected *Target.CineStep + Protected CurrentPos.CineStep + Protected ElapsedTime.q + Protected n.l + ForEach Cinematic() + If Cinematic()\StartTime<>-1 + + ElapsedTime=ElapsedMilliseconds()-Cinematic()\StartTime + + If ElapsedTime>Cinematic()\Duration + + Cinematic()\StepIndex=Cinematic()\StepIndex+1 + Cinematic()\StartTime=ElapsedMilliseconds() + ElapsedTime=0 + EndIf + If Cinematic()\StepIndex>=0 And Cinematic()\StepIndex-2 + If CreateDirectory(GetPDataDirectory("")) + Debug "Create Directory" + Else + Debug "ERROR Create Directory" + EndIf + EndIf + Protected DBFileName.s = GetPDataDirectory("HighScore.Dat") + Debug "InitDatabase() "+DBFileName + If FileSize(DBFileName)=-1 + Debug "Create DATABASE" + If CreateFile(0,DBFileName) + CloseFile(0) + If OpenDatabase(#Db, DBFileName, "", "", #PB_Database_SQLite) = 0 + MessageRequester("Error", "Impossible d'ouvir la base de donnée") + End + ElseIf DatabaseUpdate(#Db, "BEGIN TRANSACTION"); + Protected Sql.s + Sql.s="CREATE TABLE [Scores] (" + Sql+"[Id] INTEGER NULL PRIMARY KEY AUTOINCREMENT," + Sql+"[Pseudo] VARCHAR( 8)," + Sql+"[Difficulty] INTEGER NULL," + Sql+"[Score] INTEGER NULL," + Sql+"[Duration] INTEGER NULL," + Sql+"[PiecesPerMinute] INTEGER NULL," + Sql+"[LoopsPerMinute] INTEGER NULL," + Sql+"[AveragePiecesPerLoop] INTEGER NULL," + Sql+"[NbLoop] INTEGER NULL," + Sql+"[BigestLoopSize] INTEGER NULL," + Sql+"[Bonus_JewelBlue] INTEGER NULL," + Sql+"[Bonus_JewelRed] INTEGER NULL," + Sql+"[Bonus_JewelGreen] INTEGER NULL," + Sql+"[EmptyBench] INTEGER NULL," + Sql+"[Date] Text," + Sql+"[FPS_Max] INTEGER NULL," + Sql+"[FPS_Min] INTEGER NULL," + Sql+"[Resolution] Text NULL" + Sql+")"; + Debug Sql + + If DatabaseUpdate(#Db,Sql) = 0 + DbError(Sql.s) + EndIf + If DatabaseUpdate(#Db, "COMMIT")=0 + DbError(Sql.s) + EndIf + EndIf + EndIf + Else + If OpenDatabase(#Db, DBFileName, "", "", #PB_Database_SQLite) = 0 + MessageRequester("Error", "Impossible d'ouvir la base de donnée") + End + Else + Debug "DATABASE INIT OK" + If Not DatabaseUpdate(#Db,"Select Bonus_JewelGreen from Scores") + Debug "OLD Database ...i update"; + DatabaseUpdate(#Db,"ALTER TABLE [Scores] ADD [AveragePiecesPerLoop] INTEGER NULL") + DatabaseUpdate(#Db,"ALTER TABLE [Scores] ADD [Bonus_JewelGreen] INTEGER NULL") + + EndIf + EndIf + EndIf +EndProcedure + +;-################ +;-Server Database + +Procedure.s TalkToServer(Action.s,Json.s) + Protected HttpRequest.i + Protected ClientKey.s="KaLkug1265" + Protected Send.s + Protected Checksum.s + Protected StatusCode.s + Protected reponse.s + + NewMap Header$() + ;Header$("Content-Type") = "text/plain" + Header$("User-Agent") = "Loopz" + + Send.s="Action="+Action + Send+"&Data="+Json + Checksum=StringFingerprint(ClientKey+Json, #PB_Cipher_MD5) + Send+"&CheckSum="+Checksum + Send+"&Version="+#Version + CompilerIf #UsePreProdServer=#True + Send+"&OnlyToTest=0" + CompilerElse + Send+"&OnlyToTest=0" + CompilerEndIf + Debug Send + Debug "Server:"+Game\ServerAddress + HttpRequest = HTTPRequest(#PB_HTTP_Post, Game\ServerAddress, Send,0,Header$()) + If HttpRequest + ;Debug HTTPInfo(HTTPRequest, #PB_HTTP_Headers) + StatusCode=HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode) + Reponse=HTTPInfo(HTTPRequest, #PB_HTTP_Response) + Debug "StatusCode: " +StatusCode + Debug "Response: " + Reponse + Debug "___" + FinishHTTP(HTTPRequest) + If StatusCode="200" + ProcedureReturn Reponse + EndIf + Else + DisplayWarning("Http Request creation failed") + EndIf + DisplayWarning("Server Error "+Statuscode+Chr(13)+ reponse) + ProcedureReturn "" +EndProcedure +Procedure.s GetAnyValue(Value) + Select JSONType(Value) + Case #PB_JSON_Null: ProcedureReturn "null" + Case #PB_JSON_String: ProcedureReturn GetJSONString(Value) + Case #PB_JSON_Number: ProcedureReturn StrD(GetJSONDouble(Value)) + Case #PB_JSON_Boolean: ProcedureReturn Str(GetJSONBoolean(Value)) + Case #PB_JSON_Array: ProcedureReturn "array" + Case #PB_JSON_Object: ProcedureReturn "object" + EndSelect +EndProcedure + + +Procedure SaveScoreToServerDB() + Protected Json.s + Protected Reponse.s + Game\ScoreData\Resolution=GetCurrentResolution() + Game\ScoreData\Os=#CompileVersion + Game\ScoreData\GameVersion=#Version + Game\ScoreData\ComputerName=ComputerName() + Game\ScoreData\UserName=UserName() + If CreateJSON(0) + InsertJSONStructure(JSONValue(0), @Game\ScoreData, ScoreData) + Json=ComposeJSON(0, #PB_JSON_PrettyPrint) + FreeJSON(0) + EndIf + Reponse=TalkToServer("SendScore",Json) + Protected NewMap JsonAnswer() + If Reponse<>"" + If ParseJSON(0, Reponse) + If JSONType(JSONValue(0))=#PB_JSON_Object + ExtractJSONMap(JSONValue(0),JsonAnswer()) + If FindMapElement(JsonAnswer(),"Id") + Game\LastInsertIdServer=JsonAnswer("Id") + EndIf + If FindMapElement(JsonAnswer(),"Rank") + Debug " Rank="+JsonAnswer("Rank") + EndIf + ProcedureReturn #True + Else + DisplayWarning("ERROR JSON is not Object:"+Chr(13)+Reponse) + ProcedureReturn #False + EndIf + FreeJSON(0) + Else + Debug "JSon Repond From Server:"+JSONErrorMessage()+Chr(13)+Reponse + DisplayWarning("ERROR Can't Parse JSON :"+Chr(13)+Reponse) + ProcedureReturn #False + EndIf + EndIf +EndProcedure + +Procedure LoadHallOfFameFromServer(Difficulty.l) + Protected Json.s + Protected Reponse.s + Protected ObjectValue.i + Protected Result.b + ClearList(Game\Hof()) + If CreateJSON(0) + ObjectValue = SetJSONObject(JSONValue(0)) + SetJSONInteger(AddJSONMember(ObjectValue, "Difficulty"), Difficulty) + SetJSONInteger(AddJSONMember(ObjectValue, "LastInsertId"), Game\LastInsertIdServer) + Debug "LastInsertIDServer="+Str(Game\LastInsertIdServer) + Json=ComposeJSON(0, #PB_JSON_PrettyPrint) + FreeJSON(0) + EndIf + Reponse=TalkToServer("GetHallOfFame",Json) + + If reponse<>"" And ParseJSON(0, Reponse) + ObjectValue = JSONValue(0) + + ;Get HoF + If GetJSONMember(JSONValue(0), "HoF") And JSONType(GetJSONMember(JSONValue(0), "HoF"))=#PB_JSON_Array + ExtractJSONList(GetJSONMember(JSONValue(0) , "HoF"), Game\Hof()) + Result=#True + EndIf + + ;Get Error + Protected Error.s + If GetJSONMember(JSONValue(0), "Error") + Error.s=GetJSONString(GetJSONMember(JSONValue(0), "Error")) + If Error<>"" + DisplayWarning("Server ERROR :"+Error) + EndIf + EndIf + + FreeJSON(0) + + + ProcedureReturn Result + Else + DisplayWarning("ERROR Can't Parse JSON :"+Chr(13)+Reponse) + ProcedureReturn #False + EndIf +EndProcedure + + + + +; IDE Options = PureBasic 6.12 beta 4 LTS (Windows - x64) +; CursorPosition = 22 +; Folding = --- +; EnableXP \ No newline at end of file diff --git a/Datas/LoopzFont.dat b/Datas/LoopzFont.dat new file mode 100644 index 0000000000000000000000000000000000000000..b3fe1f8b464f8da059e4a4f080a9b9f190b93399 GIT binary patch literal 1442 zcmZ9L&r4Kc6o#*5GrJZsOBcFpBeb*>Erdcy`mq`!s6_(>&aQ+aDul?O1Tm>3WH4w` z&=5n50pX((EL=!wtL%Shm4pkQH{S!}ci`pR=f3BDbI!SUdhZmD3OONV#UM)P98#P{ z3C$x#4JGssDT1$b?ePmzLVwMZ=K29Hh<=pNf_c=um2vMu4B{+GXu^EMylMVwUhL+A zxP%hg&iLXXZW7_Y%eYk9?_bThopGhSzh0D3oS)}b<{xH1o%Po<{*-YK`{}Ho%y``# z`#H{jR3E%#j`vk&Kl0xqyx*d3{`qU)pb* z7tK}rmtQqE&9mlH^e_Lh`J4HX`2zjR|7b4LuQ>X9ZGK~ajQ-`%nSYrZW>RsI9`xNO zq%4m5qdY5)-+ymjaQzsb{OI?)`M3Qh{mY*=5757O%G@@`{?5?9{P=%PWxSm6wmJ5B zp853rHJ{%ykD5tEK~M4jRqo_t%qNcb`^6mfmpNO0?CX#DCbtu+;mMEhX~!Jj!#wlK zA0{RA!#rX>!aVZtnrF;Wzh>UB-(Wt~$N5l^;OOsvhNJ&}=8+$~V!q|`PB4%Bc%Prm ex9tz%$$w&AH9s_uGmre1xr=_q_ssXr@%%2l{`*>^f!SH?;eh;5+xBHLb&+z$9 zyZ;pa4qxuJ`!C^cuYI3|m*MfK-Jge7;mLlxkNTRSPu|OTA6GB$&%>+mqO;4MiHa%^6+Vr&PY17lD=SBS|_q6G0)6=G>O;4MiHa%^6+Vr&P oY17lDr%g|ro;E#gdfN1~>1or`rl(EMu70C?+Vr&PY17mG1+)OH!vFvP literal 0 HcmV?d00001 diff --git a/EarthQuake.pbi b/EarthQuake.pbi new file mode 100644 index 0000000..b96ac34 --- /dev/null +++ b/EarthQuake.pbi @@ -0,0 +1,114 @@ +Structure EQE + X.l + Y.l + Sprite.l +EndStructure + +Structure EarthQuake + WaitStartTime.i ;Start with ElapsedMilliseconds() + StartTime.i ;0 Stoped / Time run + State.b ;0 start 1 break 2 Stop + Sprite.l + DeltaX.l + DeltaY.l + List FallElement.EQE() +EndStructure + +Global EarthQuake.EarthQuake + +Procedure NewEarthQuake() + EarthQuake\StartTime=ElapsedMilliseconds() + ;SetMessage("Earth Quake") +EndProcedure + +Procedure StartEarthQuake() + EarthQuake\WaitStartTime=ElapsedMilliseconds()-Game\Difficulty(Game\ScoreData\Difficulty)\EarthQuakeTimer +EndProcedure + +Procedure RunEarthQuake() + Protected.l n,Bx,By + If ElapsedMilliseconds()-EarthQuake\WaitStartTime>Game\Difficulty(Game\ScoreData\Difficulty)\EarthQuakeTimer + EarthQuake\StartTime=ElapsedMilliseconds() + NewMessage("Earth Quake") + PlaySound(#Snd_EarthQuake) + EarthQuake\WaitStartTime=ElapsedMilliseconds() + EndIf + + If EarthQuake\StartTime>0 + Protected Time.l=ElapsedMilliseconds()-EarthQuake\StartTime + Protected QuakeSize.l + Select EarthQuake\State + Case 0 + QuakeSize.l=GUI\QuarterBlockSize*Time/800 + If Time>800 + EarthQuake\State=1 + EarthQuake\StartTime=ElapsedMilliseconds() + EndIf + Case 1 + QuakeSize.l=GUI\QuarterBlockSize + If Time>800 + EarthQuake\State=2 + EarthQuake\StartTime=ElapsedMilliseconds() + EndIf + Case 2 + QuakeSize.l=GUI\QuarterBlockSize-(GUI\QuarterBlockSize*Time/800) + If Time>800 + EarthQuake\State=0 + EarthQuake\StartTime=0 + EarthQuake\DeltaX=0 + EarthQuake\DeltaY=0 + EndIf + EndSelect + If QuakeSize<0:QuakeSize=0:EndIf ; Random(): Max Value can't be negative. + EarthQuake\DeltaX=Random(QuakeSize) + EarthQuake\DeltaY=Random(QuakeSize) + EndIf + + + If EarthQuake\State=1 And ListSize(EarthQuake\FallElement())=0 + For n=0 To Game\Difficulty(Game\ScoreData\Difficulty)\NbPieceEarthQuake + Bx=Random(17) + + By=Random(7) + + If Game\GameTable(Bx,By)\Selected=0 And Game\GameTable(Bx,By)\Sprite>0 + AddElement(EarthQuake\FallElement()) + EarthQuake\FallElement()\X=GUI\BenchX+Bx*GUI\BlockSize + EarthQuake\FallElement()\Y=GUI\BenchY+By*GUI\BlockSize + EarthQuake\FallElement()\Sprite=Game\GameTable(Bx,By)\Sprite + Game\GameTable(Bx,By)\Sprite=0 + EndIf + Next + EarthQuake\State=2 + EndIf + + + +EndProcedure + +Procedure DisplayEarthQuakeFall() + If ListSize(EarthQuake\FallElement())>0 + Protected.l TmpX,TmpY,Spr + + ForEach(EarthQuake\FallElement()) + EarthQuake\FallElement()\Y=EarthQuake\FallElement()\Y+GUI\QuarterBlockSize + TmpX=EarthQuake\FallElement()\X + TmpY=EarthQuake\FallElement()\Y + Spr=EarthQuake\FallElement()\Sprite + DisplayClipSprite(#Spr_Black,TmpX,TmpY,255) + DisplayClipSprite(Spr,TmpX,TmpY,255) + If EarthQuake\FallElement()\Y>ScreenHeight() + DeleteElement(EarthQuake\FallElement()) + If ListSize(EarthQuake\FallElement())=0 + EarthQuake\State=2 + + EndIf + EndIf + Next + EndIf +EndProcedure +; IDE Options = PureBasic 6.00 Beta 7 (Windows - x64) +; CursorPosition = 33 +; FirstLine = 22 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/Easing.pbi b/Easing.pbi new file mode 100644 index 0000000..67225e7 --- /dev/null +++ b/Easing.pbi @@ -0,0 +1,753 @@ +;- Easing + Enumeration + #Easing_Linear + + #Easing_ExpoEaseOut + #Easing_ExpoEaseIn + #Easing_ExpoEaseInOut + #Easing_ExpoEaseOutIn + + #Easing_QuadEaseOut + #Easing_QuadEaseIn + #Easing_QuadEaseInOut + #Easing_QuadEaseOutIn + + #Easing_CubicEaseOut + #Easing_CubicEaseIn + #Easing_CubicEaseInOut + #Easing_CubicEaseOutIn + + #Easing_QuartEaseOut + #Easing_QuartEaseIn + #Easing_QuartEaseInOut + #Easing_QuartEaseOutIn + + #Easing_QuintEaseOut + #Easing_QuintEaseIn + #Easing_QuintEaseInOut + #Easing_QuintEaseOutIn + + #Easing_CircEaseOut + #Easing_CircEaseIn + #Easing_CircEaseInOut + #Easing_CircEaseOutIn + + #Easing_SineEaseOut + #Easing_SineEaseIn + #Easing_SineEaseInOut + #Easing_SineEaseOutIn + + #Easing_ElasticEaseOut + #Easing_ElasticEaseIn + #Easing_ElasticEaseInOut + #Easing_ElasticEaseOutIn + + #Easing_BounceEaseOut + #Easing_BounceEaseIn + #Easing_BounceEaseInOut + #Easing_BounceEaseOutIn + + #Easing_BackEaseOut + #Easing_BackEaseIn + #Easing_BackEaseInOut + #Easing_BackEaseOutIn + + #Easing_End + EndEnumeration + + #MAX_EASING=$10000 + + Global Dim EASING.f(#Easing_End-1, #MAX_EASING) + + + ;-Expo + + CompilerIf Defined(Easing_ExpoEaseOut, #PB_Constant) Or Defined(Easing_ExpoEaseOutIn,#PB_Constant) + Procedure.f ExpoEaseOut(Fraction.f) + If Fraction=1 : ProcedureReturn 1 : Else : ProcedureReturn (-Pow(2, -10 * Fraction) + 1) : EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseIn,#PB_Constant) Or Defined(Easing_ExpoEaseOutIn,#PB_Constant) + ; Easing equation function for an exponential (2^t) easing in: + ; accelerating from zero velocity. + Procedure.f ExpoEaseIn(Fraction.f) + If Fraction=0 : ProcedureReturn 0 : Else : ProcedureReturn Pow(2, 10 * (Fraction-1)) : EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseInOut,#PB_Constant) + ; Easing equation function for an exponential (2^t) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f ExpoEaseInOut(Fraction.f) + If (Fraction=0) + ProcedureReturn 0 + ElseIf (Fraction=1) + ProcedureReturn 1 + EndIf + + Fraction * 2 + If (Fraction<1) + ProcedureReturn 0.5 * Pow(2, 10 * (Fraction - 1)) + Else + ProcedureReturn 0.5 * (-Pow(2, -10 * (Fraction - 1)) + 2) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseOutIn,#PB_Constant) + ; Easing equation function for an exponential (2^t) easing out/in: + ; deceleration until halfway, then acceleration. + Procedure.f ExpoEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5 * ExpoEaseOut(2*Fraction) + Else + ProcedureReturn 0.5 + 0.5 * ExpoEaseIn(2*Fraction - 1) + EndIf + EndProcedure + CompilerEndIf + + ;-Quadratic + + CompilerIf Defined(Easing_QuadEaseOut,#PB_Constant) Or Defined(Easing_QuadEaseOutIn,#PB_Constant) + ; Easing equation function for a quadratic (t^2) easing out: + ; decelerating from zero velocity. + Procedure.f QuadEaseOut(Fraction.f) + ProcedureReturn -Fraction * (Fraction - 2) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuadEaseIn,#PB_Constant) Or Defined(Easing_QuadEaseOutIn,#PB_Constant) + ; Easing equation function for a quadratic (t^2) easing in: + ; accelerating from zero velocity. + Procedure.f QuadEaseIn(Fraction.f) + ProcedureReturn Fraction * Fraction + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuadEaseInOut,#PB_Constant) + ; Easing equation function for a quadratic (t^2) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f QuadEaseInOut(Fraction.f) + Fraction * 2 + If (Fraction<1) + ProcedureReturn 0.5 * Fraction * Fraction + Else + Fraction-1 + ProcedureReturn -0.5 * (Fraction * (Fraction - 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuadEaseOutIn,#PB_Constant) + ; Easing equation function for a quadratic (t^2) easing out/in: + ; deceleration until halfway, then acceleration. + Procedure.f QuadEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5 * QuadEaseOut(Fraction * 2); + Else + ProcedureReturn 0.5 + 0.5 * QuadEaseIn((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_CubicEaseOut,#PB_Constant) Or Defined(Easing_CubicEaseOutIn,#PB_Constant) + ; Easing equation function for a cubic (t^3) easing out: + ; decelerating from zero velocity. + Procedure.f CubicEaseOut(Fraction.f) + Fraction - 1 + ProcedureReturn Fraction * Fraction * Fraction + 1 + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_CubicEaseIn,#PB_Constant) Or Defined(Easing_CubicEaseOutIn,#PB_Constant) + ; Easing equation function for a cubic (t^3) easing in: + ; accelerating from zero velocity. + Procedure.f CubicEaseIn(Fraction.f) + ProcedureReturn Fraction * Fraction * Fraction + EndProcedure + CompilerEndIf + + ; Easing equation function for a cubic (t^3) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f CubicEaseInOut(Fraction.f) + Fraction * 2 + If (Fraction<1) + ProcedureReturn 0.5 * Fraction * Fraction * Fraction + Else + Fraction - 2 + ProcedureReturn 0.5 * (Fraction * Fraction * Fraction + 2) + EndIf + EndProcedure + + CompilerIf Defined(Easing_CubicEaseOutIn,#PB_Constant) + ; Easing equation function for a cubic (t^3) easing out/in: + ; deceleration until halfway, then acceleration. + Procedure.f CubicEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5 * CubicEaseOut(Fraction * 2) + Else + ProcedureReturn 0.5 + 0.5 * CubicEaseIn((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + ;-Quartic + CompilerIf Defined(Easing_QuartEaseOut,#PB_Constant) Or Defined(Easing_QuartEaseOutIn,#PB_Constant) + ; Easing equation function for a quartic (t^4) easing out: + ; decelerating from zero velocity. + Procedure.f QuartEaseOut(Fraction.f) + Fraction - 1 + ProcedureReturn -(Fraction * Fraction * Fraction * Fraction - 1) + EndProcedure + CompilerEndIf + CompilerIf Defined(Easing_QuartEaseIn,#PB_Constant) Or Defined(Easing_QuartEaseOutIn,#PB_Constant) + ; Easing equation function for a quartic (t^4) easing in: + ; accelerating from zero velocity. + Procedure.f QuartEaseIn(Fraction.f) + ProcedureReturn Fraction * Fraction * Fraction * Fraction + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuartEaseInOut,#PB_Constant) + ; Easing equation function for a quartic (t^4) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f QuartEaseInOut(Fraction.f) + Fraction * 2 + If (Fraction<1) + ProcedureReturn 0.5 * Fraction * Fraction * Fraction * Fraction + Else + Fraction - 2 + ProcedureReturn -0.5 * (Fraction * Fraction * Fraction * Fraction - 2) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuartEaseOutIn,#PB_Constant) + ; Easing equation function for a quartic (t^4) easing out/in: + ; deceleration until halfway, then acceleration. + Procedure.f QuartEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5 * QuartEaseOut(Fraction * 2) + Else + ProcedureReturn 0.5 + 0.5 * QuartEaseIn((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + ;-Quintic + +CompilerIf Defined(Easing_QuintEaseOut,#PB_Constant) Or Defined(Easing_QuintEaseOutIn,#PB_Constant) + ; Easing equation function for a quintic (t^5) easing out: + ; decelerating from zero velocity. + Procedure.f QuintEaseOut(Fraction.f) + Fraction - 1 + ProcedureReturn (Fraction * Fraction * Fraction * Fraction * Fraction + 1) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuintEaseIn,#PB_Constant) Or Defined(Easing_QuintEaseOutIn,#PB_Constant) + ; Easing equation function for a quintic (t^5) easing in: + ; accelerating from zero velocity. + Procedure.f QuintEaseIn(Fraction.f) + ProcedureReturn Fraction * Fraction * Fraction * Fraction * Fraction + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuintEaseInOut,#PB_Constant) + ; Easing equation function for a quintic (t^5) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f QuintEaseInOut(Fraction.f) + Fraction * 2 + If (Fraction<1) + ProcedureReturn 0.5 * Fraction * Fraction * Fraction * Fraction * Fraction + Else + Fraction - 2 + ProcedureReturn 0.5 * (Fraction * Fraction * Fraction * Fraction * Fraction + 2) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_QuintEaseOutIn,#PB_Constant) + ; Easing equation function for a quintic (t^5) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f QuintEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5*QuintEaseOut(Fraction * 2); + Else + ProcedureReturn 0.5 + 0.5*QuintEaseIn((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + + + ;- Circular + CompilerIf Defined(Easing_CircEaseOut,#PB_Constant) Or Defined(Easing_CircEaseOutIn,#PB_Constant) + ; Easing equation function for a circular (sqrt(1-t^2)) easing out: + ; decelerating from zero velocity. + Procedure.f CircEaseOut(Fraction.f) + Fraction - 1 + ProcedureReturn Sqr(1 - Fraction * Fraction) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_CircEaseIn,#PB_Constant) Or Defined(Easing_CircEaseOutIn,#PB_Constant) + ; Easing equation function for a circular (sqrt(1-t^2)) easing in: + ; accelerating from zero velocity. + Procedure.f CircEaseIn(Fraction.f) + ProcedureReturn - (Sqr(1 - Fraction * Fraction) - 1) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_CircEaseInOut,#PB_Constant) + ; Easing equation function for a circular (sqrt(1-t^2)) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f CircEaseInOut(Fraction.f) + Fraction * 2 + If (Fraction<1) + ProcedureReturn -0.5 * (Sqr(1 - Fraction * Fraction) - 1) + Else + Fraction - 2 + ProcedureReturn 0.5 * (Sqr(1 - Fraction * Fraction) + 1) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_CircEaseOutIn,#PB_Constant) + ; Easing equation function for a circular (sqrt(1-t^2)) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f CircEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5*CircEaseOut(Fraction * 2) + Else + ProcedureReturn 0.5 + 0.5*CircEaseIn((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + +;-Sine + CompilerIf Defined(Easing_SineEaseOut,#PB_Constant) Or Defined(Easing_SineEaseOutIn,#PB_Constant) + ; Easing equation function for a sinusoidal (sin(t)) easing out: + ; decelerating from zero velocity. + Procedure.f SineEaseOut(Fraction.f) + ProcedureReturn Sin(Fraction * (#PI / 2)) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_SineEaseIn,#PB_Constant) Or Defined(Easing_SineEaseOutIn,#PB_Constant) + ; Easing equation function for a sinusoidal (sin(t)) easing in: + ; accelerating from zero velocity. + Procedure.f SineEaseIn(Fraction.f) + ProcedureReturn - Cos(Fraction * (#PI / 2)) + 1 + EndProcedure + CompilerEndIf + + ; Easing equation function for a sinusoidal (sin(t)) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f SineEaseInOut(Fraction.f) + ProcedureReturn -0.5 * (Cos(Fraction*#PI) - 1) + EndProcedure + + CompilerIf Defined(Easing_SineEaseOutIn,#PB_Constant) + ; Easing equation function for a sinusoidal (sin(t)) easing in/out: + ; deceleration until halfway, then acceleration. + Procedure.f SineEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5*SineEaseOut(Fraction * 2) + Else + ProcedureReturn 0.5 + 0.5*SineEaseIn((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + + ;-Elastic + + CompilerIf Defined(Easing_ElasticEaseOut,#PB_Constant) Or Defined(Easing_ElasticEaseOutIn,#PB_Constant) + ; Easing equation function for an elastic (exponentially decaying sine wave) easing out: + ; decelerating from zero velocity. + Procedure.f ElasticEaseOut(Fraction.f) + If (Fraction=1) + ProcedureReturn 1 + EndIf + + Protected p.f=0.3 + Protected s.f=p / 4 + ProcedureReturn Pow(2, -10 * Fraction) * Sin((Fraction - s) * (2 * #PI) / p) + 1 + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_ElasticEaseIn,#PB_Constant) Or Defined(Easing_ElasticEaseOutIn,#PB_Constant) + ; Easing equation function for an elastic (exponentially decaying sine wave) easing in: + ; accelerating from zero velocity. + Procedure.f ElasticEaseIn(Fraction.f) + If (Fraction=1) + ProcedureReturn 1 + EndIf + + Protected p.f=0.3 + Protected s.f=p / 4 + Fraction - 1 + ProcedureReturn -Pow(2, 10 * Fraction) * Sin((Fraction - s) * (2 * #PI) / p) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_ElasticEaseInOut,#PB_Constant) + ; Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f ElasticEaseInOut(Fraction.f) + Fraction * 2 + If (Fraction=2) + ProcedureReturn 1 + EndIf + + Protected p.f=(0.3 * 1.5) + Protected s.f=p / 4 + If (Fraction<1) + Fraction - 1 + ProcedureReturn -0.5 * (Pow(2, 10 * Fraction) * Sin((Fraction - s) * (2 * #PI) / p)) + Else + Fraction - 1 + ProcedureReturn 0.5 * (Pow(2, -10 * Fraction) * Sin((Fraction - s) * (2 * #PI) / p)) + 1 + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_ElasticEaseOutIn,#PB_Constant) + ; Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: + ; deceleration until halfway, then acceleration. + Procedure.f ElasticEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5*ElasticEaseOut(Fraction * 2) + Else + ProcedureReturn 0.5 + 0.5*ElasticEaseIn((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + +;-Bounce + + CompilerIf Defined(Easing_BounceEaseOut,#PB_Constant) Or Defined(Easing_BounceEaseOutIn,#PB_Constant) Or Defined(Easing_BounceEaseInOut,#PB_Constant) + ; Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: + ; decelerating from zero velocity. + Procedure.f BounceEaseOut(Fraction.f) + If (Fraction<(1 / 2.75)) + ProcedureReturn (7.5625 * Fraction * Fraction) + ElseIf (Fraction<(2 / 2.75)) + Fraction - (1.5 / 2.75) + ProcedureReturn (7.5625 * Fraction * Fraction + 0.75) + ElseIf (Fraction<(2.5 / 2.75)) + Fraction - (2.25 / 2.75) + ProcedureReturn (7.5625 * Fraction * Fraction + 0.9375) + Else + Fraction - (2.625 / 2.75) + ProcedureReturn (7.5625 * Fraction * Fraction + 0.984375) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_BounceEaseIn,#PB_Constant) Or Defined(Easing_BounceEaseOutIn,#PB_Constant) Or Defined(Easing_BounceEaseInOut,#PB_Constant) + ; Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: + ; accelerating from zero velocity. + Procedure.f BounceEaseIn(Fraction.f) + ProcedureReturn 1 - BounceEaseOut(1 - Fraction) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_BounceEaseInOut,#PB_Constant) + ; Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f BounceEaseInOut(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5*BounceEaseIn(Fraction * 2) + Else + ProcedureReturn 0.5 + 0.5*BounceEaseOut((Fraction * 2) - 1) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_BounceEaseOutIn,#PB_Constant) + ; Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: + ; deceleration until halfway, then acceleration. + Procedure.f BounceEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5*BounceEaseOut(Fraction * 2) + EndIf + + ProcedureReturn 0.5 + 0.5*BounceEaseIn(Fraction * 2 - 1) + EndProcedure + CompilerEndIf + + + + ;-Back + CompilerIf Defined(Easing_BackEaseOut,#PB_Constant) Or Defined(Easing_BackEaseOutIn,#PB_Constant) + ; Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: + ; decelerating from zero velocity. + Procedure.f BackEaseOut(Fraction.f) + Fraction - 1 + ProcedureReturn Fraction * Fraction * ((1.70158 + 1) * Fraction + 1.70158) + 1 + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_BackEaseIn,#PB_Constant) Or Defined(Easing_BackEaseOutIn,#PB_Constant) + ; Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: + ; accelerating from zero velocity. + Procedure.f BackEaseIn(Fraction.f) + ProcedureReturn Fraction * Fraction * ((1.70158 + 1) * Fraction - 1.70158) + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_BackEaseInOut,#PB_Constant) + ; Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: + ; acceleration until halfway, then deceleration. + Procedure.f BackEaseInOut(Fraction.f) + Protected s.f=1.70158 + Fraction * 2 + If (Fraction<1) + s * (1.525) + ProcedureReturn 0.5 * (Fraction * Fraction * ((s + 1) * Fraction - s)) + Else + Fraction - 2 + s * (1.525) + ProcedureReturn 0.5 * (Fraction * Fraction * ((s + 1) * Fraction + s) + 2) + EndIf + EndProcedure + CompilerEndIf + + CompilerIf Defined(Easing_BackEaseOutIn,#PB_Constant) + ; Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: + ; deceleration until halfway, then acceleration. + Procedure.f BackEaseOutIn(Fraction.f) + If (Fraction<0.5) + ProcedureReturn 0.5*BackEaseOut(Fraction * 2) + EndIf + + ProcedureReturn 0.5 + 0.5*BackEaseIn((Fraction * 2) - 1) + EndProcedure + CompilerEndIf + ;-FIN procedure + Procedure InitEase() + Protected i + For i=0 To #MAX_EASING + CompilerIf Defined(Easing_Linear, #PB_Constant) + EASING(#Easing_Linear,i)=i/#MAX_EASING + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseOut,#PB_Constant) + EASING(#Easing_ExpoEaseOut,i)=ExpoEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseIn,#PB_Constant) + EASING(#Easing_ExpoEaseIn,i)=ExpoEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseInOut,#PB_Constant) + EASING(#Easing_ExpoEaseInOut,i)=ExpoEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseOutIn,#PB_Constant) + EASING(#Easing_ExpoEaseOutIn,i)=ExpoEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ExpoEaseOutIn,#PB_Constant) + EASING(#Easing_ExpoEaseOutIn,i)=ExpoEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuadEaseOut,#PB_Constant) + EASING(#Easing_QuadEaseOut,i)=QuadEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuadEaseIn,#PB_Constant) + EASING(#Easing_QuadEaseIn,i)=QuadEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuadEaseInOut,#PB_Constant) + EASING(#Easing_QuadEaseInOut,i)=QuadEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuadEaseOutIn,#PB_Constant) + EASING(#Easing_QuadEaseOutIn,i)=QuadEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_CubicEaseOut,#PB_Constant) + EASING(#Easing_CubicEaseOut,i)=CubicEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_CubicEaseIn,#PB_Constant) + EASING(#Easing_CubicEaseIn,i)=CubicEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_CubicEaseInOut,#PB_Constant) + EASING(#Easing_CubicEaseInOut,i)=CubicEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_CubicEaseOutIn,#PB_Constant) + EASING(#Easing_CubicEaseOutIn,i)=CubicEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuartEaseOut,#PB_Constant) + EASING(#Easing_QuartEaseOut,i)=QuartEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuartEaseIn,#PB_Constant) + EASING(#Easing_QuartEaseIn,i)=QuartEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuartEaseInOut,#PB_Constant) + EASING(#Easing_QuartEaseInOut,i)=QuartEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuartEaseOutIn,#PB_Constant) + EASING(#Easing_QuartEaseOutIn,i)=QuartEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuintEaseOut,#PB_Constant) + EASING(#Easing_QuintEaseOut,i)=QuintEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuintEaseIn,#PB_Constant) + EASING(#Easing_QuintEaseIn,i)=QuintEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuintEaseInOut,#PB_Constant) + EASING(#Easing_QuintEaseInOut,i)=QuintEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_QuintEaseOutIn,#PB_Constant) + EASING(#Easing_QuintEaseOutIn,i)=QuintEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_CircEaseOut,#PB_Constant) + EASING(#Easing_CircEaseOut,i)=CircEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_CircEaseIn,#PB_Constant) + EASING(#Easing_CircEaseIn,i)=CircEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_CircEaseInOut,#PB_Constant) + EASING(#Easing_CircEaseInOut,i)=CircEaseInOut(i/#MAX_EASING) + CompilerEndIf + + + + CompilerIf Defined(Easing_CircEaseOutIn,#PB_Constant) + EASING(#Easing_CircEaseOutIn,i)=CircEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_SineEaseOut,#PB_Constant) + EASING(#Easing_SineEaseOut,i)=SineEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_SineEaseIn,#PB_Constant) + EASING(#Easing_SineEaseIn,i)=SineEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_SineEaseInOut,#PB_Constant) + EASING(#Easing_SineEaseInOut,i)=SineEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_SineEaseOutIn,#PB_Constant) + EASING(#Easing_SineEaseOutIn,i)=SineEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ElasticEaseOut,#PB_Constant) + EASING(#Easing_ElasticEaseOut,i)=ElasticEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ElasticEaseIn,#PB_Constant) + EASING(#Easing_ElasticEaseIn,i)=ElasticEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ElasticEaseInOut,#PB_Constant) + EASING(#Easing_ElasticEaseInOut,i)=ElasticEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_ElasticEaseOutIn,#PB_Constant) + EASING(#Easing_ElasticEaseOutIn,i)=ElasticEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BounceEaseOut,#PB_Constant) + EASING(#Easing_BounceEaseOut,i)=BounceEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BounceEaseIn,#PB_Constant) + EASING(#Easing_BounceEaseIn,i)=BounceEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BounceEaseInOut,#PB_Constant) + EASING(#Easing_BounceEaseInOut,i)=BounceEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BounceEaseOutIn,#PB_Constant) + EASING(#Easing_BounceEaseOutIn,i)=BounceEaseOutIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BackEaseOut,#PB_Constant) + EASING(#Easing_BackEaseOut,i)=BackEaseOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BackEaseIn,#PB_Constant) + EASING(#Easing_BackEaseIn,i)=BackEaseIn(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BackEaseInOut,#PB_Constant) + EASING(#Easing_BackEaseInOut,i)=BackEaseInOut(i/#MAX_EASING) + CompilerEndIf + + CompilerIf Defined(Easing_BackEaseOutIn,#PB_Constant) + EASING(#Easing_BackEaseOutIn,i)=BackEaseOutIn(i/#MAX_EASING) + CompilerEndIf + +; CompilerIf Defined(Easing_ElasticEaseOut, #PB_Constant) +; EASING(#Easing_ElasticEaseOut,i)=ElasticEaseOut(i/#MAX_EASING) +; CompilerEndIf + Next + EndProcedure + + InitEase() + + +Procedure.F FractionTimer(ExecutionTime, IsPingPong=#False, Duration=1000, LoopDuration=0) + If ExecutionTime<0 ; Determines if timer has started + ExecutionTime=0 + ElseIf ExecutionTime>Duration ; Determines if timer has ended + ExecutionTime=Duration + EndIf + Protected Fraction.f + ;Convert to Loop if necessary + If LoopDuration + Fraction=Mod(ExecutionTime, LoopDuration) / LoopDuration + Else + Fraction=ExecutionTime / Duration + EndIf + ;Convert to PingPong if necessary + If IsPingPong + Fraction=1-Abs(2*Fraction-1) + EndIf + ProcedureReturn Fraction +EndProcedure + +Procedure.f GetEasingPosValue(StartValue.f, FinishValue.f,StartTime.q, Duration.l, Easing.l) + Protected CurrentTime.q=ElapsedMilliseconds()-StartTime + Protected i=#MAX_EASING*CurrentTime/Duration + Protected Result.f,Distance.f + If i<0 + Result=0 + ElseIf i>#MAX_EASING + Result=1 + Else + Result=EASING(Easing, i);#MAX_EASING + EndIf + Distance=FinishValue-StartValue + Protected.f Position=StartValue+Distance*Result + ProcedureReturn Position +EndProcedure +; IDE Options = PureBasic 6.00 Beta 6 (Windows - x64) +; CursorPosition = 739 +; FirstLine = 676 +; Folding = --------------------- +; EnableXP \ No newline at end of file diff --git a/Fontcreator.pb b/Fontcreator.pb new file mode 100644 index 0000000..a63e9a4 --- /dev/null +++ b/Fontcreator.pb @@ -0,0 +1,95 @@ +UsePNGImageEncoder() +UsePNGImageDecoder() +font.i= LoadFont(#PB_Any,"Arial",96) + + +Structure myFontData + x.l + y.l + Width.l + Height.l +EndStructure + +Dim myFontData.myFontData(256) +AsciiStart.c=33 +AsciiEnd.c=122 +;Repeat + +;Until +If IsFont(font) +MaxWidth=0 +MaxHeight=0 +CreateImage(0,1024,1024,32,#PB_Image_Transparent) +StartDrawing(ImageOutput(0)) +DrawingFont(FontID(font)) + +For a=AsciiStart To AsciiEnd + myFontData(a)\Width=TextWidth(Chr(a)) + myFontData(a)\Height=TextHeight(Chr(a)) + If myFontData(a)\Width>MaxWidth:MaxWidth=myFontData(a)\Width:EndIf + If myFontData(a)\Height>MaxHeight:MaxHeight=myFontData(a)\Height:EndIf +Next +StopDrawing() +FreeImage(0) + +;Classique ; + +If MaxWidth>MaxHeight + Max=MaxWidth +Else + Max=MaxHeight +EndIf +Debug "Size="+Str(Max) +Marg=4 +CreateImage(0,(Max+Marg*2)*10,(Max+Marg*2)*10,32,#PB_Image_Transparent) +StartDrawing(ImageOutput(0)) +DrawingFont(FontID(font)) +x.l=0:y.l=0 +For a=AsciiStart To AsciiEnd + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Outlined ) + Box(x,y,Max+Marg*2,Max+Marg*2,RGBA(0,255,0,128)) + + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend) + DrawText(x+Marg,y+Marg,Chr(a),RGBA(255,255,255,255)) + Line(x+Marg+myFontData(a)\Width,y,1,Max,RGBA(255,0,0,200)) + Debug Chr(a)+" width="+Str(myFontData(a)\Width) + x=x+Max+Marg*2 + If x+Max+Marg*2>ImageWidth(0):x=0:y=y+Max+Marg*2:EndIf + +Next +StopDrawing() +SaveImage(0,"Fonts.png",#PB_ImagePlugin_PNG) +FreeImage(0) +;optimized +CreateImage(0,(Max+Marg*2)*10,(Max+Marg*2)*10,32,#PB_Image_Transparent) +StartDrawing(ImageOutput(0)) +DrawingFont(FontID(font)) +x.l=0:y.l=0 +Dim finalFont.myFontData(90) +For a=AsciiStart To 122 + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend) + If x+myFontData(a)\Width+Marg*2>ImageWidth(0) + x=0:Y=Y+MaxHeight+Marg*2 + EndIf + DrawText(x+Marg,y+Marg,Chr(a),RGBA(255,255,255,255)) + finalFont(a-33)\x=x + finalFont(a-33)\y=y + finalFont(a-33)\Width=myFontData(a)\Width+Marg*2 + finalFont(a-33)\Height=MaxHeight+Marg*2 + x=x+myFontData(a)\Width+Marg*2 +Next +Y=Y+MaxHeight+Marg*2 +Line(0,Y,ImageWidth(0),1,RGBA(255,0,0,255)) +StopDrawing() +SaveImage(0,"FontsCompress.png",#PB_ImagePlugin_PNG) +If CreateFile(0,"FontsCompress.dat") + WriteCharacter(0,AsciiStart,#PB_Ascii) + WriteCharacter(0,AsciiEnd,#PB_Ascii) + WriteData(0,@finalFont(),SizeOf(myFontData)*ArraySize(finalFont())) + CloseFile(0) +EndIf +EndIf +; IDE Options = PureBasic 6.00 Beta 5 (Windows - x64) +; CursorPosition = 85 +; FirstLine = 18 +; EnableXP \ No newline at end of file diff --git a/GUI.pbi b/GUI.pbi new file mode 100644 index 0000000..54469fa --- /dev/null +++ b/GUI.pbi @@ -0,0 +1,79 @@ +;- Init Game param Structure + +#MaxTableWidth=17 +#MaxTableHeight=6 + +Structure GUIParam + FullScreen.l ; #True = Fullscreen / #False = WindowScreen (not .b use .l to be compatible with Option menu) + ScreenResolutionWidth.l ; Width Resolution in FullScreen + ScreenResolutionHeight.l ; Height Resolution in FullScreen + ScreenResolutionDepth.l + List ScreenResolution.s() + ScreenResolutionIndex.l + + WindowResolutionWidth.l ; Width Résolution in WindowScreen + WindowResolutionHeight.l ; Height Résolution in WindowScreen + List WindowResolution.s() + WindowResolutionIndex.l + WindowX.l + WindowY.l + + FPS.l ;FPS + fpsValue.l ;Current FPS Value + + ;Unit to Display GUI + BlockSize.l ; 1 Unit + HalfBlockSize.l ; 1/2 Unit + DoubleBlockSize.l ; 2 Unit + QuarterBlockSize.l ; 1/4 Unit + ScreenWidth.f + ScreenHeight.f + + JewelRed_X.f + JewelBlue_X.f + + ;Bench Position Init in IniScreen() + BenchX.l + BenchY.l + BenchWidth.l + BenchHeight.l + ;Timer Position Init in IniScreen() + TimerX.l + TimerY.l + TimerWidth.l +EndStructure + +Global GUI.GUIParam +GUI\FullScreen=#True + +;Get All Screen Resolution +If ExamineScreenModes() + ClearList(GUI\ScreenResolution()) + AddElement(GUI\ScreenResolution()) + GUI\ScreenResolution()="Auto" + While NextScreenMode() + If ScreenModeRefreshRate()>=60 + AddElement(GUI\ScreenResolution()) + GUI\ScreenResolution()=Str(ScreenModeWidth())+"x"+Str(ScreenModeHeight())+"x"+Str(ScreenModeDepth())+"@"+Str(ScreenModeRefreshRate())+"Hz" + EndIf + Wend +EndIf + +;Get Window Resolution +ClearList(GUI\WindowResolution()) +;4/3 +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="640x480" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="800x600";, 960×720, 1024×768, 1280×960, 1400×1050, 1440×1080 , 1600×1200, 1856×1392, 1920×1440, And 2048×1536 +;16/9 +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="1024x576" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="1152x648" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="1280x720" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="1366x768" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="1600x900" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="1920x1080" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="2560x1440" +AddElement(GUI\WindowResolution()):GUI\WindowResolution()="3840x2160" +; IDE Options = PureBasic 6.00 LTS (Windows - x64) +; CursorPosition = 48 +; FirstLine = 2 +; EnableXP \ No newline at end of file diff --git a/Game.pbi b/Game.pbi new file mode 100644 index 0000000..29a7702 --- /dev/null +++ b/Game.pbi @@ -0,0 +1,1824 @@ + + +Procedure ResetGame() + MouseLocate(ScreenWidth()/2,(GUI\BenchHeight+GUI\BenchY)/2) + Game\Life=Game\Difficulty(Game\ScoreData\Difficulty)\NbLife + Game\ScoreData\Score=0 + Game\ScoreData\NbLoop=0 + Game\ScoreData\BenchIsEmpty=0 + Game\Combo=0 + Game\UnfinishedLoopCount=0 + Game\Timer=Game\Difficulty(Game\ScoreData\Difficulty)\Timer + Game\WaitTimer=0 + EarthQuake\StartTime=0 + Game\LittlePieceCounter=0 ;If Game\NbPiecesOnBench>70 count little piece and when Game\LittlePieceCounter>Game\Difficulty(#Level_Hard)\NbLittlePiece a bigger piece see: Shape.Pbi RandomShape() + Game\NbPiecesOnBench=0 + EarthQuake\WaitStartTime=ElapsedMilliseconds() + + Game\NextTime=ElapsedMilliseconds()+Game\Timer + Game\ScoreData\BigestLoopSize=0 + ClearList(LoopPath()) + ;ClearList(Game\Bonus\DisplayedBonus()) + Protected.l Bx,By,n + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + Game\GameTable(Bx,By)\Sprite=0 + Game\GameTable(Bx,By)\Selected=#False + Game\GameTable(Bx,By)\BonusOnThisCase=#False + Next + Next + Game\ScoreData\Bonus_JewelRed=0 + Game\ScoreData\Bonus_JewelBlue=0 + Game\ScoreData\Bonus_JewelGreen=0 + ;reset State + For n=0 To 5 + Stats\NbItemByGroup(n)=0 + Next + For n=0 To #Bonus_End + Stats\NbBonus(n)=0 + Next + ClearList(Stats\PieceTime()) + ClearList(Stats\LoopTime()) + ClearList(Stats\NbPieces()) + ClearList(Bonus\DisplayedBonus()) + Stats\StartGameTimer=ElapsedMilliseconds() + Stats\StartLoopTimer=ElapsedMilliseconds() + Stats\BigestLoopSize=0 + Stats\NbLoop=0 + Stats\Bonus_JewelBlue=0 + Stats\Bonus_JewelRed=0 + Stats\Bonus_JewelGreen=0 + Stats\BenchIsEmpty=0 + Bonus\Dead_StartTimer=ElapsedMilliseconds() + Bonus\Random_StartTime=ElapsedMilliseconds() + Bonus\Random_Duration=5000 + Bonus\HammerEnable=#False + Bonus\RemoveEnable=#False + Bonus\X2Enable=#False + Bonus\FreezeEnable=#False + Select Game\ScoreData\Difficulty + Case #Level_Novice + Bonus\EyeEnable=#True + Case #Level_Normal + Bonus\EyeEnable=#True + Case #Level_Hard + Bonus\EyeEnable=#False + Case #Level_Madness + Bonus\EyeEnable=#False + EndSelect + Game\ScoreData\Fps_Max=0 + Game\ScoreData\Fps_Min=99999 +EndProcedure + + +Procedure InitGameMode(Mode.l) + Game\ComeFromMode=Game\Mode + Game\Mode=Mode + Game\ToggleMode=0 + + + + Protected *Obj_Sprite.SpriteData + Protected *Obj_Text.TextData + Protected Text.s + ;Protected *Step + Protected n.l + Debug "InitGameMode="+Str(Mode) + Select Mode + Case #Mode_record + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + If IsMusic(Game\CurrentMusic):StopMusic(Game\CurrentMusic):EndIf + Game\CurrentMusic=-1 + Game\DisplayCursor=#False + ;-Init Mode Intro + Case #Mode_Intro + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + StartMusic(#Music_Intro,#True) + + *Obj_Sprite=NewSprite(#Spr_Thy,10,(GUI\ScreenHeight/2),-1,-1,0,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,500,2000,0,255,0) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,2000,1000,255,255,0) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,3000,1000,255,0,0) + + ;*Obj_Sprite=NewSprite(#Spr_Presente,10,(GUI\ScreenHeight/2),-1,-1,0,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + *Obj_Text=NewText(0,"Presents",ScreenWidth()/2,ScreenHeight()/2,0,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,3000,2000,0,255,0) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,5000,1000,255,255,0) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,6000,2000,255,0,0) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,12000,2000,0,2,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,12000,2000,0,2,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,(GUI\ScreenHeight/2),-1,-1,0,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,7000,4000,0,255,0) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,11000,1000,255,255,0) + AddmoveToEngine(@*Obj_Sprite\y,#PB_Float,12000,2000,(GUI\ScreenHeight/2),1,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,(GUI\ScreenHeight/2),-1,-1,0,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,9500,1000,0,255,0) + AddmoveToEngine(@*Obj_Sprite\y,#PB_Float,12100,2000,(GUI\ScreenHeight/2),1,#Easing_ElasticEaseOut,1000+#Mode_Menu) + + Game\DisplayCursor=#False + ;-Init Mode Menu + Case #Mode_Menu + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + StartMusic(#Music_Intro) + ;TO DO TEST Server connection + ;If Game\ConnectToServer=#True + ; DisplayWarning("No Web Connection") + ;EndIf + + Protected *MenuOption.MenuOption + NewMenu("Game Menu") + *MenuOption=AddMenuOption("Start Game",#Mode_Game_Init) + *MenuOption=AddMenuOption("Difficulty",-1,-1,"Novice|Normal|Hard|Madness",@Game\ScoreData\Difficulty) + *MenuOption=AddMenuOption("Options",#Mode_Options) + *MenuOption=AddMenuOption("JukeBox",#Mode_JukeBox) + If Game\ConnectToServer=#False + *MenuOption=AddMenuOption("Hall Of Fame",#Mode_HallOfFame) + Else + *MenuOption=AddMenuOption("World Hall Of Fame",#Mode_HallOfFame) + EndIf + *MenuOption=AddMenuOption("Credits",#Mode_Credits) + FinalizeMenu() + + AddItemToDisplayEngine(0,#Type_DisplayMenu) + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + Game\DisplayCursor=#True + + ;-Init Mode Options + Case #Mode_Options + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + NewMenu("Options") + *MenuOption=AddMenuOption("Score On Internet",-1,-1,"No|Yes",@Game\ConnectToServer) + *MenuOption=AddMenuOption("Fluid Cursor",-1,-1,"No|Yes",@Game\FluidCursor) + *MenuOption=AddMenuOption("Graphics",#Mode_Graphics) + *MenuOption=AddMenuOption("Audios",#Mode_Audios) + *MenuOption=AddMenuOption("Return",#Mode_Menu) + FinalizeMenu() + AddItemToDisplayEngine(0,#Type_DisplayMenu) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + ;-Init Mode Graphics + Case #Mode_Graphics + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + Protected txt.s="" + NewMenu("Graphics") + *MenuOption=AddMenuOption("FullScreen",-1,-1,"No|Yes",@GUI\FullScreen) + ForEach GUI\ScreenResolution() + Txt+GUI\ScreenResolution()+"|" + Next + Txt=Left(Txt,Len(Txt)-1) ; Delete Last "|" + *MenuOption=AddMenuOption("Screen Resolution",-1,-1,Txt,@GUI\ScreenResolutionIndex) + + txt="" + ForEach GUI\WindowResolution() + Txt+GUI\WindowResolution()+"|" + Next + Txt=Left(Txt,Len(Txt)-1) ; Delete Last "|" + *MenuOption=AddMenuOption("Window Resolution",-1,-1,Txt,@GUI\WindowResolutionIndex) + *MenuOption=AddMenuOption("Save",-1,#EventGui_NewResolution) + FinalizeMenu() + AddItemToDisplayEngine(0,#Type_DisplayMenu) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + ;-Init Mode Audios + Case #Mode_Audios + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + NewMenu("Audio") + *MenuOption=AddMenuOption("Music",-1,#EventGui_ChangeMusicVolume,"0%|10%|20%|30%|40%|50%|60%|70%|80%|90%|100%",@Game\VolumeMusic) + *MenuOption=AddMenuOption("Sfx",-1,#EventGui_ChangeSfxVolume,"0%|10%|20%|30%|40%|50%|60%|70%|80%|90%|100%",@Game\VolumeSfx) + *MenuOption=AddMenuOption("Return",#Mode_Options) + FinalizeMenu() + AddItemToDisplayEngine(0,#Type_DisplayMenu) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + ;-Init JukeBox + Case #Mode_JukeBox + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + NewMenu("JukeBox") + *MenuOption=AddMenuOption("Select Music",-1,#EventGui_ChangeVinyl,"Intro|Game Novice/Normal|Game Hard/Madness|GameMissed|GameOver|HighScore|Credits",@Game\JukeBoxIndex) + *MenuOption=AddMenuOption("Return",#Mode_Menu) + FinalizeMenu() + StopMusic(game\CurrentMusic) + Game\CurrentMusic =-1 ; To force To play if play same music played before + PlaySound(#Snd_Jukebox) + + Game\ObjetVinyl=NewSprite(#Spr_Vinyl,22,GUI\ScreenHeight/2,-1,-1,255,2,#Spr_Depth_Front,#Align_Hor_Right|#Align_Ver_Middle) + AddItemToDisplayEngine(Game\ObjetVinyl,#Type_Sprite) + AddmoveToEngine(@Game\ObjetVinyl\X,#PB_Float,0,2000,24,20,0,#EventGui_PlayJukeBox) + + AddItemToDisplayEngine(0,#Type_DisplayMenu) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + + + + ;-Init Mode Credits + Case #Mode_Credits + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + StartMusic(#Music_Credits,#True) + + AddTitle("Credits",1) + TitlesCenter(#True) + AddTitle("Original Concept By Ian Upton",0) + AddTitle("Graphics by Yann Lebrun",0) + AddTitle("Code by Yann Lebrun",0) + AddTitle("Music by Alex Menchi",0) + AddTitle("SFX by mixkit.co - freesound.org",0) + AddTitle("",0) + AddTitle("Mindphazer MacOs Test",0) + AddTitle("",0) + AddTitle("Musical Themes inspired by",1) + AddTitle("David Wittaker",0) + AddTitle("Alexandre Ekian",0) + AddTitle("Stephane Picq",0) + AddTitle("",0) + AddTitle("Thanks",1) + AddTitle("Delphine Le Philippe",0) + AddTitle("",0) + AddTitle("Other Thanks",1) + Addtitle("Frederic Laboureur",0) + Addtitle("Alain (Poum) Massoumipour",0) + Addtitle("Jay Miner",0) + + AddTitle("",0) + AddTitle("Big Up!",1) + AddTitle("Purebasic community",0) + AddTitle("Amiga and Amstrad community",0) + AddTitle("Roller Skating Family",0) + AddTitle("St Joseph Team",0) + AddTitle("Frederic (scr33tch) Boisdron",0) + AddTitle("Walid (Hybrid) Moghrabi",0) + AddTitle("Eric (Titan) Cubizolle",0) + AddTitle("Pascal (Deckard) Visa",0) + AddTitle("Jesahel (Djes) Benoist",0) + AddTitle("",0) + AddTitle("",0) + AddTitle("",0) + AddTitle("",0) + AddTitle("",0) + AddTitle("",0) + AddTitle("",0) + AddTitle("",0) + AddTitle("Don't Forget, there is a worm in Apple !") + Titles\LineSpacing=0 + Titles\Alpha=255 + Titles\Speed=10000 + Titles\ScrollY=0 + AddItemToDisplayEngine(0,#Type_DisplayTitle) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + ;-Init Mode Game Init + Case #Mode_Game_Init + RandomSeed(ElapsedMilliseconds()) + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + If Game\ScoreData\Difficulty<2 + StartMusic(#Music_GameA,#True) + Else + StartMusic(#Music_GameB,#True) + EndIf + + ResetGame() + + *Obj_Sprite=NewSprite(#Spr_Sc,1,8,3,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,2000,-3,1,#Easing_ElasticEaseIn) + + *Obj_Sprite=NewSprite(#Spr_Sc,GUI\ScreenWidth-4,8,3,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,2000,GUI\ScreenWidth,GUI\ScreenWidth-4,#Easing_ElasticEaseIn) + + + Protected.l Bx,By + Protected.f SX,SY,EX,EY + Protected.l Angle + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + SX=GUI\ScreenWidth/2+#MaxTableWidth*Cos(Angle) + SY=GUI\ScreenHeight/2+#MaxTableWidth*Sin(Angle) + Angle=Angle+2 + If (Bx+(By*#MaxTableWidth))%2 + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + Else + *Obj_Sprite=NewSprite(#Spr_BenchB,0,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + EndIf + Protected time.l=Random(3000,2000) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,1000,time,SX,BX+1,#Easing_ElasticEaseOut) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,1000,time,SY,BY+1,#Easing_ElasticEaseOut) + Next + Next + AddmoveToEngine(0,0,0,3000,0,0,0,1000+#Mode_Game_Run) + + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,0,2000,2,0,#Easing_ElasticEaseIn) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,0,2000,2,0,#Easing_ElasticEaseIn) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,0,2000,255,0,0) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,1,-2,#Easing_ElasticEaseIn) + ;-Init Mode Game Run + Case #Mode_Game_Run + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayBench) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayCursor) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayTimer) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayScore) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayMessage) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayBonus) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayEarthQuakeFall) + + Game\ObjetBlueJewel=NewSprite(#Spr_JewelBlue,8,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetBlueJewel,#Type_Sprite) + AddmoveToEngine(@Game\ObjetBlueJewel\Opacity,#PB_Float,0,2000,0,255,0) + Game\ObjetBlueJewelValue=NewText(0,"x"+Str(Game\ScoreData\Bonus_JewelBlue),(8+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetBlueJewelValue,#Type_BitmapText) + AddmoveToEngine(@Game\ObjetBlueJewelValue\Opacity,#PB_Long,0,2000,0,255,0) + + Game\ObjetRedJewel=NewSprite(#Spr_JewelRed,11,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetRedJewel,#Type_Sprite) + AddmoveToEngine(@Game\ObjetRedJewel\Opacity,#PB_Float,0,2000,0,255,0) + Game\ObjetRedJewelValue=NewText(0,"x"+Str(Game\ScoreData\Bonus_JewelRed),(11+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetRedJewelValue,#Type_BitmapText) + AddmoveToEngine(@Game\ObjetRedJewelValue\Opacity,#PB_Long,0,2000,0,255,0) + + Game\ObjetGreenJewel=NewSprite(#Spr_JewelGreen,14,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetGreenJewel,#Type_Sprite) + AddmoveToEngine(@Game\ObjetGreenJewel\Opacity,#PB_Float,0,2000,0,255,0) + Game\ObjetGreenJewelValue=NewText(0,"x"+Str(Game\ScoreData\Bonus_JewelGreen),(14+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetGreenJewelValue,#Type_BitmapText) + AddmoveToEngine(@Game\ObjetGreenJewelValue\Opacity,#PB_Long,0,2000,0,255,0) + + + + + ResetGame() + + RunEarthQuake() + + NewMessage("Let's Go !!!") + ;-Init Mode GameOver + Case #Mode_GameOver + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + + StartMusic(#Music_GameOver,#True) + + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayBench) + ;AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayCursor) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayScore) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayMessage) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayBonus) + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayEarthQuakeFall) + ;AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayTimer) + + Game\ObjetBlueJewel=NewSprite(#Spr_JewelBlue,8,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetBlueJewel,#Type_Sprite) + Game\ObjetBlueJewelValue=NewText(0,"x"+Str(Game\ScoreData\Bonus_JewelBlue),(8+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetBlueJewelValue,#Type_BitmapText) + + Game\ObjetRedJewel=NewSprite(#Spr_JewelRed,11,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetRedJewel,#Type_Sprite) + Game\ObjetRedJewelValue=NewText(0,"x"+Str(Game\ScoreData\Bonus_JewelRed),(11+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetRedJewelValue,#Type_BitmapText) + + Game\ObjetGreenJewel=NewSprite(#Spr_JewelGreen,14,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetGreenJewel,#Type_Sprite) + Game\ObjetGreenJewelValue=NewText(0,"x"+Str(Game\ScoreData\Bonus_JewelGreen),(14+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetGreenJewelValue,#Type_BitmapText) + + *Obj_Text=NewText(1,"GAME OVER",ScreenWidth()/2,GUI\BenchHeight/2+GUI\BlockSize,0,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,0,2000,0,255,0) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,5000,2000,255,0,0,-1,@*Obj_Text\Autodestroy) + + Game\ScoreData\Duration=ElapsedMilliseconds()-Stats\StartGameTimer ; End Game i record party duration + + ;-Init Mode GameOver End + Case #Mode_GameOver_End + Debug ("Init Mode GameOver End") + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + + StartMusic(#Music_GameOver,#True) + + Game\StartCalculBonus=#False ; Wait End Animation Before Start Calcul + + + Protected TmpX.l + ;Blue Jewel + Game\ObjetBlueJewel=NewSprite(#Spr_JewelBlue,8,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetBlueJewel,#Type_Sprite) + Game\ObjetBlueJewelValue=NewText(0,Str(Stats\Bonus_JewelBlue)+"x10",(9+1) * GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetBlueJewelValue,#Type_BitmapText) + TmpX=20/5 + AddmoveToEngine(@Game\ObjetBlueJewel\X,#PB_Float,0,2000,8,TmpX,0) + AddmoveToEngine(@Game\ObjetBlueJewel\Y,#PB_Float,0,2000,0,3,0) + AddmoveToEngine(@Game\ObjetBlueJewelValue\X,#PB_Long,0,2000,(8+1) * GUI\BlockSize,(TmpX+1)* GUI\BlockSize,0) + AddmoveToEngine(@Game\ObjetBlueJewelValue\Y,#PB_Long,0,2000,0,3 * GUI\BlockSize,0) + + ;Red Jewel + Game\ObjetRedJewel=NewSprite(#Spr_JewelRed,11.5,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetRedJewel,#Type_Sprite) + Game\ObjetRedJewelValue=NewText(0,Str(Stats\Bonus_JewelRed)+"x20",(11+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetRedJewelValue,#Type_BitmapText) + AddmoveToEngine(@Game\ObjetRedJewelValue\Opacity,#PB_Long,0,2000,0,255,0) + TmpX=20/5*2 + AddmoveToEngine(@Game\ObjetRedJewel\X,#PB_Float,0,2000,11,TmpX,0) + AddmoveToEngine(@Game\ObjetRedJewel\Y,#PB_Float,0,2000,0,3,0) + AddmoveToEngine(@Game\ObjetRedJewelValue\X,#PB_Long,0,2000,(11+1) * GUI\BlockSize,(TmpX+1)* GUI\BlockSize,0) + AddmoveToEngine(@Game\ObjetRedJewelValue\Y,#PB_Long,0,2000,0,3 * GUI\BlockSize,0) + + ;Green Jewel + Game\ObjetGreenJewel=NewSprite(#Spr_JewelGreen,14,0,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetGreenJewel,#Type_Sprite) + Game\ObjetGreenJewelValue=NewText(0,Str(Stats\Bonus_JewelGreen)+"x40",(14+1)*GUI\BlockSize,0,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetGreenJewelValue,#Type_BitmapText) + TmpX=20/5*3 + AddmoveToEngine(@Game\ObjetGreenJewel\X,#PB_Float,0,2000,14,TmpX,0) + AddmoveToEngine(@Game\ObjetGreenJewel\Y,#PB_Float,0,2000,0,3,0) + AddmoveToEngine(@Game\ObjetGreenJewelValue\X,#PB_Long,0,2000,(14+1) * GUI\BlockSize,(TmpX+1)* GUI\BlockSize,0) + AddmoveToEngine(@Game\ObjetGreenJewelValue\Y,#PB_Long,0,2000,0,3 * GUI\BlockSize,0) + + ;Jewel Score + TmpX=20/5*4 + Game\ObjetText[0]=NewText(0,"= 00000",TmpX * GUI\BlockSize,3 * GUI\BlockSize,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetText[0],#Type_BitmapText) + AddmoveToEngine(@Game\ObjetText[0]\X,#PB_Long,0,2000,ScreenWidth(),TmpX* GUI\BlockSize,#Easing_ElasticEaseOut) + + ;Biggest Loop + Game\ObjetText[1]=NewText(0,"Biggest Loop "+MyFormatNumber("00",Stats\BigestLoopSize)+" x 5",(TmpX-1)* GUI\BlockSize,4*GUI\BlockSize,255,#Spr_Depth_Front,#Align_Hor_Right|#Align_Ver_Top) + AddItemToDisplayEngine(Game\ObjetText[1],#Type_BitmapText) + ;AddmoveToEngine(@*Obj_Text\X,#PB_Long,1000,4000,-*Obj_Text\Width,6*GUI\BlockSize,0) + + Game\ObjetText[2]=NewText(0,"= 00000",TmpX * GUI\BlockSize,4 * GUI\BlockSize,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetText[2],#Type_BitmapText) + AddmoveToEngine(@Game\ObjetText[2]\X,#PB_Long,0,2000,ScreenWidth(),TmpX* GUI\BlockSize,#Easing_ElasticEaseOut) + + ;Number of Loops + Game\ObjetText[3]=NewText(0,"Number of Loops "+MyFormatNumber("00",Stats\NbLoop)+" x 10",(TmpX-1)* GUI\BlockSize,5 * GUI\BlockSize,255,#Spr_Depth_Front,#Align_Hor_Right|#Align_Ver_Top) + AddItemToDisplayEngine(Game\ObjetText[3],#Type_BitmapText) + + Game\ObjetText[4]=NewText(0,"= 00000",TmpX * GUI\BlockSize,5 * GUI\BlockSize,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetText[4],#Type_BitmapText) + AddmoveToEngine(@Game\ObjetText[4]\X,#PB_Long,0,2000,ScreenWidth(),TmpX* GUI\BlockSize,#Easing_ElasticEaseOut) + + ;Cleaned Bench + Game\ObjetText[5]=NewText(0,Str(Stats\BenchIsEmpty)+" Cleaned Bench x 500",(TmpX-1)* GUI\BlockSize,6 * GUI\BlockSize,255,#Spr_Depth_Front,#Align_Hor_Right|#Align_Ver_Top) + AddItemToDisplayEngine(Game\ObjetText[5],#Type_BitmapText) + Game\ObjetText[6]=NewText(0,"= 00000",TmpX * GUI\BlockSize,6 * GUI\BlockSize,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetText[6],#Type_BitmapText) + AddmoveToEngine(@Game\ObjetText[6]\X,#PB_Long,0,2000,ScreenWidth(),TmpX* GUI\BlockSize,#Easing_ElasticEaseOut) + + ;Bonus Score + *Obj_Text=NewText(1,"Bonus",(TmpX-1)* GUI\BlockSize,7 * GUI\BlockSize,255,#Spr_Depth_Front,#Align_Hor_Right|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + Game\ObjetText[7]=NewText(1,"= 00000",TmpX * GUI\BlockSize,7 * GUI\BlockSize,255,#Spr_Depth_Front) + AddItemToDisplayEngine(Game\ObjetText[7],#Type_BitmapText) + AddmoveToEngine(@Game\ObjetText[7]\X,#PB_Long,0,2000,ScreenWidth(),TmpX* GUI\BlockSize,#Easing_ElasticEaseOut) + + Game\ObjetText[8]=NewText(0,"",ScreenWidth()/2,8 * GUI\BlockSize,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(Game\ObjetText[8],#Type_BitmapText) + ; Bench + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + SX=GUI\ScreenWidth/2+#MaxTableWidth*Cos(Angle) + SY=GUI\ScreenHeight/2+#MaxTableWidth*Sin(Angle) + Angle=Angle+2 + If (Bx+(By*#MaxTableWidth))%2 + *Obj_Sprite=NewSprite(#Spr_BenchA,BX+1,BY+1,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + Else + *Obj_Sprite=NewSprite(#Spr_BenchB,BX+1,BY+1,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + EndIf + time.l=Random(2000,1000) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,time,BX+1,SX,#Easing_ElasticEaseIn,-1,@*Obj_Sprite\AutoDestroy) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,time,BY+1,SY,#Easing_ElasticEaseIn,-1,@*Obj_Sprite\AutoDestroy) + Next + Next + AddmoveToEngine(0,0,0,2000,0,0,0,#EventGui_StartCalculBonus) + + + + + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,0,2000,0,2,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,0,2000,0,2,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,0,2000,0,255,0) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,-2,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,-2,1,#Easing_ElasticEaseOut) + + Case -1 + + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + + StartMusic(#Music_GameOver,#True) + + Game\StartCalculBonus=#False ; Wait End Animation Before Start Calcul + + *Obj_Text=NewText(1,"Bonus",(ScreenWidth()- TextBitmapWidth("Bonus")) / 2,GUI\BlockSize*2,255,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + + Protected.f Y=3*GUI\BlockSize: + Protected.l X=13*GUI\BlockSize + + ;CalculBonus\BonusA=NewText(0,"Biggest "+MyFormatNumber("00",Stats\BigestLoopSize)+" x 1",6*GUI\BlockSize,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusA,#Type_BitmapText) + ;AddmoveToEngine(@*Obj_Text\X,#PB_Long,1000,4000,-*Obj_Text\Width,6*GUI\BlockSize,0) + + ;CalculBonus\BonusAResult=NewText(0,"= "+Str(Stats\BigestLoopSize*10),X,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusAResult,#Type_BitmapText) + + Y=Y+GUI\BlockSize + + ;CalculBonus\BonusB=NewText(0,MyFormatNumber("000",Stats\NbLoop)+" Loops x 10",6*GUI\BlockSize,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusB,#Type_BitmapText) + + ; CalculBonus\BonusBResult=NewText(0,"= "+Str(Stats\NbLoop*10),X,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusBResult,#Type_BitmapText) + + Y=Y+GUI\BlockSize + + ;CalculBonus\BonusC=NewText(0,MyFormatNumber("00",Stats\Bonus_JewelBlue)+" x 20",9*GUI\BlockSize,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusC,#Type_BitmapText) + *Obj_Sprite=NewSprite(#Spr_JewelBlue,8,Y/GUI\BlockSize,-1,-1,255,1) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,1000,1500,GUI\JewelBlue_X / GUI\BlockSize,8,0) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,1000,1500,0,Y/GUI\BlockSize,0) + ; CalculBonus\BonusCResult=NewText(0,"= "+Str(Stats\Bonus_JewelBlue*20),X,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusCResult,#Type_BitmapText) + + Y=Y+GUI\BlockSize + + ;CalculBonus\BonusD=NewText(0,MyFormatNumber("00",Stats\Bonus_JewelRed)+" x 20",9*GUI\BlockSize,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusD,#Type_BitmapText) + *Obj_Sprite=NewSprite(#Spr_JewelRed,8,Y/GUI\BlockSize,-1,-1,255,1) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,1000,1500,GUI\JewelRed_X / GUI\BlockSize,8,0) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,1000,1500,0,Y/GUI\BlockSize,0) + ;CalculBonus\BonusDResult=NewText(0,"= "+Str(Stats\Bonus_JewelRed*20),X,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusDResult,#Type_BitmapText) + + Y=Y+GUI\BlockSize + + ;CalculBonus\BonusE=NewText(0,Str(Stats\BenchIsEmpty)+" Cleaned Bench x 500",3*GUI\BlockSize,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusE,#Type_BitmapText) + + ;CalculBonus\BonusEResult=NewText(0,"= "+Str(Stats\BenchIsEmpty*500),X,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusEResult,#Type_BitmapText) + + Y=Y+GUI\BlockSize*1 + + ;CalculBonus\BonusF=NewText(1,"Score",9*GUI\BlockSize,Y,255,#Spr_Depth_Front) + ; AddItemToDisplayEngine(CalculBonus\BonusF,#Type_BitmapText) + + ;CalculBonus\BonusFResult=NewText(1,"= "+MyFormatNumber("00000",Game\ScoreData\Score),X,Y,255,#Spr_Depth_Front) + ;AddItemToDisplayEngine(CalculBonus\BonusFResult,#Type_BitmapText) + + *Obj_Sprite=NewSprite(#Spr_Sc,1,8,3,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,2000,1,-3,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_Sc,GUI\ScreenWidth-4,8,3,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,2000,GUI\ScreenWidth-4,GUI\ScreenWidth,#Easing_ElasticEaseOut) + + + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + SX=GUI\ScreenWidth/2+#MaxTableWidth*Cos(Angle) + SY=GUI\ScreenHeight/2+#MaxTableWidth*Sin(Angle) + Angle=Angle+2 + If (Bx+(By*#MaxTableWidth))%2 + *Obj_Sprite=NewSprite(#Spr_BenchA,BX+1,BY+1,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + Else + *Obj_Sprite=NewSprite(#Spr_BenchB,BX+1,BY+1,-1,-1,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + EndIf + time.l=Random(2000,1000) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,time,BX+1,SX,#Easing_ElasticEaseIn) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,time,BY+1,SY,#Easing_ElasticEaseIn) + Next + Next + AddmoveToEngine(0,0,0,2000,0,0,0,#EventGui_StartCalculBonus) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,0,2000,0,2,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,0,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Height,#PB_Float,0,2000,0,2,#Easing_ElasticEaseOut) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Opacity,#PB_Float,0,2000,0,255,0) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,-2,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,-2,1,#Easing_ElasticEaseOut) + + *Obj_Text=NewText(0,"Press Space to SpeedUp",ScreenWidth()/2,ScreenHeight()-GUI\BlockSize,0,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,2000,2000,0,255,0) + + ;-Init Mode Enter Your Name + Case #Mode_EnterYourName + Debug ("Init Mode Enter Your Name") + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + ClearMoveEngine() + + *Obj_Text=NewText(1,"Score "+MyFormatNumber("00000",Game\ScoreData\Score),ScreenWidth()/2,GUI\DoubleBlockSize,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Y,#PB_Long,0,1000,ScreenHeight(),GUI\DoubleBlockSize,#Easing_ElasticEaseOut) + + *Obj_Text=NewText(0,"Enter your name",ScreenWidth()/4,GUI\BlockSize*3.5,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,0,1000,0,255,0) + + Game\ObjetText[0]=NewText(1,Game\ScoreData\Pseudo,ScreenWidth()/4,GUI\BlockSize*5,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(Game\ObjetText[0],#Type_BitmapText) + AddmoveToEngine(@Game\ObjetText[0]\X,#PB_Long,0,1000,-Game\ObjetText[0]\X,ScreenWidth()/4,#Easing_ElasticEaseOut) + + Game\ObjetText[8]=NewText(0,"Return to Continue",ScreenWidth()/2,8 * GUI\BlockSize,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(Game\ObjetText[8],#Type_BitmapText) + + ;Calcul Rythme + n=0 + Protected PieceTime.f,LoopTime.f + If ListSize(Stats\PieceTime())>0 ;If No Piece = Infiny + ForEach Stats\PieceTime() + n=n+Stats\PieceTime() + Next + PieceTime=n/ListSize(Stats\PieceTime()) + Game\ScoreData\PiecesPerMinute=60/(PieceTime/1000) + Else + Game\ScoreData\PiecesPerMinute=-1 + EndIf + + n=0; + ForEach Stats\LoopTime() + n=n+Stats\LoopTime() + Next + If ListSize(Stats\LoopTime())>0 ; If No Loop = Infiny + LoopTime=n/ListSize(Stats\LoopTime()) + Game\ScoreData\LoopsPerMinute=60/(LoopTime/1000) + Else + Game\ScoreData\LoopsPerMinute=-1 + EndIf + + n=0; + ForEach Stats\NbPieces() + n=n+Stats\NbPieces() + Next + If ListSize(Stats\NbPieces())>0 + Game\ScoreData\AveragePiecesPerLoop=n/ListSize(Stats\NbPieces()) + EndIf + + *Obj_Text=NewText(0,"Your Rythme",ScreenWidth()*3/4,GUI\BlockSize*3.5,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Opacity,#PB_Long,0,1000,0,255,0) + + *Obj_Text=NewText(0,StrF(Game\ScoreData\PiecesPerMinute,2)+" Pieces/Min",ScreenWidth()*3/4,GUI\BlockSize*5,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Y,#PB_Long,0,1800,ScreenHeight(),GUI\BlockSize*5,#Easing_ElasticEaseOut) + + *Obj_Text=NewText(0,StrF(Game\ScoreData\LoopsPerMinute,2)+" Loops/Min",ScreenWidth()*3/4,GUI\BlockSize*6,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Y,#PB_Long,0,1900,ScreenHeight(),GUI\BlockSize*6,#Easing_ElasticEaseOut) + + *Obj_Text=NewText(0,StrF(Game\ScoreData\AveragePiecesPerLoop,2)+" Pieces/Loop",ScreenWidth()*3/4,GUI\BlockSize*7,255,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + AddmoveToEngine(@*Obj_Text\Y,#PB_Long,0,2000,ScreenHeight(),GUI\BlockSize*7,#Easing_ElasticEaseOut) + + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + ;-Init Mode HallOfFame + Case #Mode_HallOfFame + Debug ("Init Mode HallOfFame") + ClearAllSprite() + ClearTitles() + ClearAllText() + ClearDisplayEngine() + + StartMusic(#Music_HighScore) + + DrawingBitmapFont(0) + BitmapFont()\Tab(0)=1.5* GUI\BlockSize ;Pseudo + BitmapFont()\Tab(1)=6* GUI\BlockSize ;Score + BitmapFont()\Tab(2)=9* GUI\BlockSize ;piece time + BitmapFont()\Tab(3)=13.5* GUI\BlockSize; Lop/min + BitmapFont()\Tab(4)=18 * GUI\BlockSize ; Duration + TitlesCenter(#False) + If Game\ComeFromMode=#Mode_HallOfFame Or Game\ComeFromMode=#Mode_Menu + If Game\ConnectToServer=#True + LoadHallOfFameFromServer(Game\HallOfFameDifficultyMode) + HallofFamelistToTitle(Game\LastInsertIdServer) + Else + LoadHallOfFame(Game\HallOfFameDifficultyMode) + EndIf + TitlesEvent(#EventGui_NextHallOfFame) + Else + If Game\ConnectToServer=#True + LoadHallOfFameFromServer(Game\ScoreData\Difficulty) + HallofFamelistToTitle(Game\LastInsertIdServer) + Else + LoadHallOfFame(Game\ScoreData\Difficulty) ;<- Database.pbi + EndIf + EndIf + + + Titles\LineSpacing=0.5 + Titles\Alpha=255 + AddItemToDisplayEngine(*Obj_Sprite,#Type_DisplayTitle) + + *Obj_Sprite=NewSprite(#Spr_BckgrndFadeUp,0,2,GUI\ScreenWidth,3,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BckgrndFadeDown,0,GUI\ScreenHeight-2,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + text="Hall Of Fame" + DrawingBitmapFont(1) ;Used by TextBitmapWidth() next line + *Obj_Text=NewText(1,text,(ScreenWidth()- TextBitmapWidth(text)) / 2,GUI\DoubleBlockSize,255) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + + Protected D.l + If Game\ComeFromMode=#Mode_HallOfFame Or Game\ComeFromMode=#Mode_Menu + D=Game\HallOfFameDifficultyMode + Else + D=Game\ScoreData\Difficulty + EndIf + Select D + Case 0 ;Novice + Text="Novice" + Case 1 ;Normal + Text="Normal" + Case 2 ;Hard + Text="Hard" + Case 3 ;Madness + Text="Madness" + EndSelect + If Game\ConnectToServer=#True + text="World "+Text + EndIf + DrawingBitmapFont(0) ;Used by TextBitmapWidth() next line + *Obj_Text=NewText(0,text,(ScreenWidth()- TextBitmapWidth(text)) / 2,GUI\DoubleBlockSize+GUI\BlockSize,255) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + + *Obj_Sprite=NewSprite(#Spr_BenchA,0,0,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_BenchC,0,GUI\ScreenHeight,GUI\ScreenWidth,2,255,1,#Spr_Depth_Front,#Align_Hor_Left|#Align_Ver_Bottom) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Logo,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + *Obj_Sprite=NewSprite(#Spr_Remix,10,1,-1,-1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Top) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + EndSelect + + + +EndProcedure + +Procedure ScreenShoot() + Protected File.s + Protected n.l=-1 + If KeyboardReleased(#PB_Key_F10) + Debug "Screenshoot" + GrabSprite(100,0,0,ScreenWidth(),ScreenHeight()) + Repeat + n=n+1 + File=Str(n) + File=Left("1000",4-Len(File))+File + File=GetUserDirectory(#PB_Directory_Desktop)+"Loopz-"+File+".png" + Until FileSize(File)=-1 + SaveSprite(100,File,#PB_ImagePlugin_PNG ) + FreeSprite(100) + EndIf +EndProcedure + +Procedure DisplayBench() + Protected Bx.l + Protected By.l + Protected Tmpx.l + Protected Tmpy.l + Protected Spr.l + Protected Selected.l + DisplayClipSprite(#Spr_SelectedBackground,GUI\BenchX+ EarthQuake\DeltaX,GUI\BenchY+ EarthQuake\DeltaY,255,1,GUI\BenchWidth,GUI\BenchHeight) + Game\NbPiecesOnBench=0 + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + + TmpX=Bx * GUI\BlockSize + GUI\BenchX+ EarthQuake\DeltaX + TmpY=By * GUI\BlockSize + GUI\BenchY+ EarthQuake\DeltaY + + Spr=Game\GameTable(Bx,By)\Sprite + Selected=Game\GameTable(Bx,By)\Selected + If Spr>0 + Game\NbPiecesOnBench=Game\NbPiecesOnBench+1 + If Selected=#False + DisplayClipSprite(#Spr_Black,TmpX,TmpY,255) + EndIf + ;If Game\GameTable(Bx,By)\BonusOnThisCase=#True + ; Spr=#Spr_Black + ;EndIf + + DisplayClipSprite(Spr,TmpX,TmpY,255) + + Else + + If (Bx+(By*#MaxTableWidth))%2 + Spr=#Spr_BenchA + Else + Spr=#Spr_BenchB + EndIf + + DisplayClipSprite(Spr,TmpX,TmpY,255) + EndIf + + + Next + Next + +EndProcedure + +Procedure DisplayTimer() + ;-Timer + If Bonus\FreezeEnable=#True + If (ElapsedMilliseconds()-Bonus\FreezeStartTime)/1000>10 + Bonus\FreezeAlpha=Bonus\FreezeAlpha-1 + Bonus\FreezeTimer=Bonus\FreezeTimer-1 + If Bonus\FreezeAlpha=0 + Bonus\FreezeEnable=#False + EndIf + Else + Bonus\FreezeAlpha=255 + EndIf + Game\NextTime=ElapsedMilliseconds()+Bonus\FreezeTimer-1 + EndIf + If Game\WaitTimer=0 And Game\Timer>0 + Protected Width.l= GUI\TimerWidth * (Game\NextTime-ElapsedMilliseconds()) / Game\Timer + + DisplayClipSprite(#Spr_Black,GUI\TimerX,GUI\TimerY,255,1,GUI\TimerWidth,GUI\BlockSize) + DisplayClipSprite(#Spr_White,GUI\TimerX,GUI\TimerY,255,1,Width,GUI\BlockSize) + Protected TimerTxt.s + TimerTxt=StrF(Game\Timer/1000,1)+" Sec" + DrawBitmapText((ScreenWidth()-TextBitmapWidth(TimerTxt))/2,GUI\TimerY,TimerTxt) + + If Bonus\FreezeEnable=#True + DisplayClipSprite(#Spr_Frozen,GUI\TimerX,GUI\TimerY,Bonus\FreezeAlpha) + EndIf + + If ElapsedMilliseconds()>Game\NextTime + + RandomShape() + Game\Life=Game\Life-1 + If Game\Life>0 + StartMusic(#Music_Missed,#True) + NewMessage("Missed",0) + NewBonus(#Bonus_Time) + Game\WaitTimer=ElapsedMilliseconds()+Game\Difficulty(Game\ScoreData\Difficulty)\WaitMissed + Else + Debug "Game Over : End Timer" + Game\Mode=#Mode_GameOver + InitGameMode(#Mode_GameOver) + EndIf + EndIf + EndIf +EndProcedure + + +Procedure DisplayScore() + Protected Score.s=Str(Game\ScoreData\Score) + Score=Left("0000",4-Len(Score))+Score + Protected Width.l=TextBitmapWidth(Score) + DisplayClipSprite(#Spr_Sc,GUI\BlockSize,GUI\BenchY+GUI\BenchHeight,255,1) + DrawingBitmapFont(0) + DrawBitmapText(GUI\BenchX+((GUI\BlockSize*3)-Width)/2,GUI\BenchY+GUI\BenchHeight+GUI\HalfBlockSize, Score); + + + Protected.l Minutes,Seconds,Duration + Duration=ElapsedMilliseconds()-Stats\StartGameTimer + Minutes=(Duration/1000)/60 + Seconds=(Duration/1000)%60 + DisplayClipSprite(#Spr_Sc,ScreenWidth()-GUI\BlockSize*4,GUI\BenchY+GUI\BenchHeight,255,1) + DrawBitmapText(ScreenWidth()-GUI\BlockSize*3.5,GUI\BenchY+GUI\BenchHeight+GUI\HalfBlockSize, MyFormatNumber("00",Minutes)+":"+MyFormatNumber("00",Seconds)); + + ;-Display DIfficulty + Protected Text.s + Select Game\ScoreData\Difficulty + Case 0 ;Novice + Text="Novice" + Case 1 ;Normal + Text="Normal" + Case 2 ;Hard + Text="Hard" + Case 3 ;Madness + Text="Madness" + EndSelect + DrawBitmapText(0,0,Text) + + If Bonus\EyeEnable=#True + DrawShape(GUI\TimerX+GUI\TimerWidth+GUI\BlockSize-GUI\QuarterBlockSize,GUI\TimerY-GUI\QuarterBlockSize,Game\NextShape,128,0.5) + EndIf + + ;-Display Life + Protected n.l + Protected lifeSpace.l + If Game\Life<4 + lifeSpace=GUI\BlockSize + Else + lifeSpace=4*GUI\BlockSize/Game\Life + EndIf + For n=1 To Game\Life + DisplayClipSprite(#Spr_Health,ScreenWidth()-lifeSpace*n,0,255,1,GUI\BlockSize,GUI\BlockSize) + Next + + ;Display Jewel + Game\ObjetBlueJewelValue\String="x"+Str(Game\ScoreData\Bonus_JewelBlue); + Game\ObjetRedJewelValue\String="x"+Str(Game\ScoreData\Bonus_JewelRed); + Game\ObjetGreenJewelValue\String="x"+Str(Game\ScoreData\Bonus_JewelGreen); + + If Bonus\RemoveEnable=#True + DisplayClipSprite(#Spr_Remove,GUI\BlockSize*3,0) + ;Duration=(ElapsedMilliseconds()-Bonus\Remove_StartTime) + ;If Duration>Game\Difficulty(Game\ScoreData\Difficulty)\BonusRemoveDuration + ; Bonus\RemoveEnable=#False + ; Bonus\Remove_StartTime=0 + ;Else + ; DrawBitmapText(GUI\BlockSize*4,0,MyFormatNumber("00",(Game\Difficulty(Game\ScoreData\Difficulty)\BonusRemoveDuration-Duration)/1000)); + ;EndIf + + EndIf + + If Bonus\HammerEnable=#True + DisplayClipSprite(#Spr_Hammer,GUI\BlockSize*3,0) + Duration=(ElapsedMilliseconds()-Bonus\Hammer_StartTime) + If Duration>Game\Difficulty(Game\ScoreData\Difficulty)\BonusHammerDuration + Bonus\HammerEnable=#False + Bonus\Hammer_StartTime=0 + Else + DrawBitmapText(GUI\BlockSize*4,0,MyFormatNumber("00",(Game\Difficulty(Game\ScoreData\Difficulty)\BonusHammerDuration-Duration)/1000)); + EndIf + EndIf + + ; Bonus X2 + If Bonus\X2Enable>3 + Bonus\X2Enable=3 + EndIf + Select Bonus\X2Enable + Case 1 + DisplayClipSprite(#Spr_X2,GUI\BlockSize*5,0) + Case 2 + DisplayClipSprite(#Spr_X4,GUI\BlockSize*5,0) + Case 3 + DisplayClipSprite(#Spr_X8,GUI\BlockSize*5,0) + EndSelect + +EndProcedure + +Procedure DisplayCursor() + Protected MX.l + Protected MY.l + Protected Bx.l + Protected By.l + Protected TmpX.l + Protected TmpY.l + Static MouseBL.l + Static MouseBR.l + MX=MouseX()-GUI\BlockSize + MY=MouseY()-GUI\BlockSize + Bx=Int(MX / GUI\BlockSize) + By=Int(MY / GUI\BlockSize) + If Bx<0:Bx=0:EndIf + If By<0:Bx=0:EndIf + If Bx>#MaxTableWidth + Bx=#MaxTableWidth + EndIf + If By>#MaxTableHeight + By=#MaxTableHeight + EndIf + Game\BlockMouseX=Bx + Game\BlockMouseY=By + TmpX=Bx * GUI\BlockSize + GUI\BenchX + TmpY=By * GUI\BlockSize + GUI\BenchY + + If Game\WaitTimer>0 + ;DisplayClipSprite(#Spr_Cursor,TmpX,TmpY,255) + If ElapsedMilliseconds()>Game\WaitTimer + Game\NextTime=ElapsedMilliseconds()+Game\Timer + Game\WaitTimer=0 + EraseSelectedPieceOnBench() + EndIf + Else + + EndIf + + ;Display Cursor + If Game\FluidCursor=#True + If Not Game\WaitTimer>0 And Bonus\RemoveEnable=#False + DrawShape(MX+GUI\HalfBlockSize,MY+GUI\HalfBlockSize,Game\SelectedShape,200) + EndIf + DisplayClipSprite(#Spr_Cursor,MX+GUI\HalfBlockSize,MY+GUI\HalfBlockSize,255) + Else + If Not Game\WaitTimer>0 And Bonus\RemoveEnable=#False + DrawShape(TmpX,TmpY,Game\SelectedShape,200) + EndIf + DisplayClipSprite(#Spr_Cursor,TmpX,TmpY,255) + EndIf + + If ListSize(Bonus\DisplayedBonus())>0 + TakeBonus(Bx.l,By.l) + EndIf + + If Game\WaitTimer=0 And MouseButton(#PB_MouseButton_Left) + If MouseBL=0 + MouseBL=#PB_MouseButton_Left + If Bonus\RemoveEnable=#True + CheckLoop(Bx,By,#False) + PlaySound(#Snd_DoALoop) + ClearList(LoopPath()) ; Don't Add Jewel when no Loop + Bonus\RemoveEnable=#False + Game\WaitTimer=ElapsedMilliseconds()+1000 ; <-Wait before next piece + If Game\NbPiecesOnBench=0:Bonus\RemoveEnable=#False:EndIf + ElseIf TestShapeToBench(Bx,By,Game\SelectedShape) Or Bonus\HammerEnable=#True + Game\Timer=Game\Timer-Game\Difficulty(Game\ScoreData\Difficulty)\TimerDownValue + ;Add Stats To time to put a piece + AddElement(Stats\PieceTime()) + Stats\PieceTime()=Game\Timer-(Game\NextTime-ElapsedMilliseconds()) + Debug "PieceTime="+StrF(Stats\PieceTime()/1000)+"sec" + If Bonus\HammerEnable=#True + PlaySound(#Snd_MetalHammer) + Else + PlaySound(#Snd_PutPiece) + EndIf + InsertShapeToBench(Bx,By,Game\SelectedShape) + + RandomShape() + Protected LoopSize=CheckLoop(Bx,By) + ;-Do a Loop + If LoopSize>1 + PlaySound(#Snd_DoALoop) + Bonus\Dead_StartTimer=ElapsedMilliseconds() ; reset Dead Bonus Time + ;Add Stats To time to put a piece + EarthQuake\WaitStartTime=ElapsedMilliseconds() ; Reset EarthQuake Timer + AddElement(Stats\NbPieces()) + Stats\NbPieces()=LoopSize + AddElement(Stats\LoopTime()) + Stats\LoopTime()=ElapsedMilliseconds()-Stats\StartLoopTimer + Stats\StartLoopTimer=ElapsedMilliseconds() + Debug "LoopTime="+Str(Stats\LoopTime()/1000)+"Sec" + If LoopSize>Game\ScoreData\BigestLoopSize + Game\ScoreData\BigestLoopSize=LoopSize + If Game\ScoreData\NbLoop>1 + NewMessage("Biggest Loop",0) + EndIf + EndIf + + Game\WaitTimer=ElapsedMilliseconds()+1000 ; <-Wait before next piece + Game\ScoreData\NbLoop=Game\ScoreData\NbLoop+1 + NewMessage("Loops "+Str(Game\ScoreData\NbLoop)+" With "+Str(LoopSize)+" pieces",0 ) + Protected n.l + ;Add Jewel + + If Bonus\X2Enable>0 + Debug "A Bonus\X2Enable="+Str(Bonus\X2Enable) + LoopSize=LoopSize*Pow(2,Bonus\X2Enable) + NewMessage("Loop Score X"+Str(Pow(2,Bonus\X2Enable)),0 ) + Protected *Obj_Sprite.SpriteData + Protected Sprite.l + Select Bonus\X2Enable + Case 1 + Sprite=#Spr_X2 + Case 2 + Sprite=#Spr_X4 + Case 3 + Sprite=#Spr_X8 + EndSelect + *Obj_Sprite=NewSprite(Sprite,5,0,1,1,255,1,#Spr_Depth_Front,#Align_Hor_Middle|#Align_Ver_Middle) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + AddmoveToEngine(@*Obj_Sprite\Size,#PB_Float,0,1000,1,75,#Easing_Linear,-1,@*Obj_Sprite\AutoDestroy) + AddmoveToEngine(@*Obj_Sprite\X,#PB_Float,0,1000,5,GUI\ScreenWidth/2,#Easing_QuintEaseOut) + AddmoveToEngine(@*Obj_Sprite\Y,#PB_Float,0,1000,0,GUI\ScreenHeight/2,#Easing_QuintEaseOut) + Bonus\X2Enable=#False + Debug "B Bonus\X2Enable="+Str(Bonus\X2Enable) + EndIf + + If Game\NbCross>0 + NewMessage("Cross X "+Str(Game\NbCross)+" Bonus",0) + EndIf + + + If LoopSize>=18 + + For n=0 To LoopSize/8 + + NewBonus(#Bonus_JewelRed) + Next + + For n=0 To LoopSize/15 + NewBonus(#Bonus_JewelGreen) + Next + + EndIf + + If LoopSize>=40 + NewBonus(#Bonus_Eye) + EndIf + Game\Timer=Game\Timer-100 + + If Game\Timer<2500:Game\Timer=2500:EndIf + + If Game\Timer<=3900 + NewBonus(#Bonus_Time) + EndIf + + If LoopSize>=40 + NewBonus(#Bonus_Health) + EndIf + + Game\Combo=Game\Combo+1 + If (Game\Combo>1) + NewMessage("Combo X"+Str(Game\Combo),0 ) + EndIf + + Game\ScoreData\Score=Game\ScoreData\Score+LoopSize*10*Game\Combo + + If CheckBenchIsEmpty()=#True + Game\ScoreData\BenchIsEmpty=Game\ScoreData\BenchIsEmpty+1 + NewMessage("Empty Bench ",0 ) + Else + Debug "CheckBenchIsEmpty()=#False" + EndIf + Else + Game\Combo=0 + EndIf + ;reset Timer + Game\NextTime=ElapsedMilliseconds()+Game\Timer + Else + PlaySound(#Snd_CanTPutPiece) + Debug "NON" + EndIf + + EndIf + Else + MouseBL=0 + EndIf + + + ; Turn Piece + If Game\WaitTimer=0 And (MouseButton(#PB_MouseButton_Right) Or KeyboardPushed(#PB_Key_LeftControl) ) + If MouseBR=0 + MouseBR=#PB_MouseButton_Left + Game\SelectedShape=SP(Game\SelectedShape)\NextId + EndIf + Else + MouseBR=0 + EndIf + +EndProcedure + + + +Procedure KeyboardOrMouseClick() + Static Mb.l + If KeyboardReleased(#PB_Key_Space) Or GetLeftMouseClick() + Mb=#True + ProcedureReturn #True + Else + Mb=#False + ProcedureReturn #False + EndIf +EndProcedure + + +Procedure GameMode() + Protected Event.i + Protected n.l + Protected MB.l + ;-EVentGUI + Repeat + Event=EventGUI() + If Event>0 + ;Enumeration Event in Main.Pbi + Select Event + Case #EventGui_ChangeVinyl + ClearMoveEngine() + StopMusic(Game\CurrentMusic) + Game\CurrentMusic =-1 ; To force To play if play same music played before + PlaySound(#Snd_Jukebox) + + AddmoveToEngine(@Game\ObjetVinyl\X,#PB_Float,0,1000,Game\ObjetVinyl\X,24,0) + AddmoveToEngine(@Game\ObjetVinyl\X,#PB_Float,1000,1000,24,20,0,#EventGui_PlayJukeBox) + Case #EventGui_PlayJukeBox + + StartMusic(Game\JukeBoxIndex,#True) + Case #EventGui_AddHealth + Game\Life=Game\Life+1 + Case #EventGui_AddJewelBlue + Game\ScoreData\Bonus_JewelBlue=Game\ScoreData\Bonus_JewelBlue+1 + Case #EventGui_AddJewelRed + Game\ScoreData\Bonus_JewelRed=Game\ScoreData\Bonus_JewelRed+1 + Case #EventGui_AddJewelGreen + Game\ScoreData\Bonus_JewelGreen=Game\ScoreData\Bonus_JewelGreen+1 + Case #EventGui_AddX2 + Bonus\X2Enable=Bonus\X2Enable+1 + Case #EventGui_Dead + Game\Life=Game\Life-1 + If Game\Life>0 + NewMessage("DEAD",0) + Game\WaitTimer=ElapsedMilliseconds()+Game\Difficulty(Game\ScoreData\Difficulty)\WaitMissed + Else + Debug "Game Over : Get Dead Penalty" + InitGameMode(#Mode_GameOver) + EndIf + Case #EventGui_EnableHammer + Bonus\Hammer_StartTime=ElapsedMilliseconds() + Bonus\HammerEnable=#True + Bonus\RemoveEnable=#False + Case #EventGui_EnableRemover + Bonus\Remove_StartTime=ElapsedMilliseconds() + Bonus\RemoveEnable=#True + Bonus\HammerEnable=#False + Case #EventGui_EnableEye + Bonus\EyeEnable=#True + + Case #EventGui_EnableFreeze + Bonus\FreezeEnable=#True + Bonus\FreezeStartTime=ElapsedMilliseconds() + Bonus\FreezeTimer=Game\NextTime-ElapsedMilliseconds() + PlaySound(#Snd_Freeze) + Case #EventGui_NextHallOfFame + Game\HallOfFameDifficultyMode=Game\HallOfFameDifficultyMode+1 + If Game\HallOfFameDifficultyMode>=3:Game\HallOfFameDifficultyMode=0:EndIf + InitGameMode(#Mode_HallOfFame) + Case #EventGui_NewResolution + DeInitScreen() + InitNewResolution() + InitScreen() + InitGameMode(#Mode_Menu) + Case #EventGui_ChangeMusicVolume + For n=0 To #Music_End-1 + MusicVolume(n,Game\VolumeMusic*10) + Next + Case #EventGui_ChangeSfxVolume + ;SoundVolume(#PB_All,Game\VolumeSfx*10) + For n=0 To #Snd_End-1 + SoundVolume(n,Game\VolumeSfx*10) + Next + PlaySound(#Snd_GetBonus) + Case #EventGui_StartCalculBonus + Game\StartCalculBonus=#True + StartMusic(#Music_HighScore,#True) + + + + EndSelect + If Event>999 + InitGameMode(Event-1000) + EndIf + + EndIf + Until Event=0 + ;DrawTitles() + + Select Game\Mode + Case #Mode_record + If KeyboardOrMouseClick() + InitGameMode(#Mode_Intro) + + EndIf + ;-Mode Intro + Case #Mode_Intro + If KeyboardOrMouseClick() + InitGameMode(#Mode_Menu) + EndIf + ; DisplaySprites() + ;-Mode Menu + Case #Mode_Menu,#Mode_Options,#Mode_Graphics,#Mode_Audios + If KeyboardReleased(#PB_Key_F9) + InitGameMode(#Mode_record) + EndIf + + ;-Init JukeBox + Case #Mode_JukeBox + + + ;-Mode Credits + Case #Mode_Credits + + If KeyboardOrMouseClick() + InitGameMode(#Mode_Menu) + + EndIf + ;-Mode Game Init + Case #Mode_Game_Init + Stats\StartGameTimer=ElapsedMilliseconds() ; Always 00:00 when Game Init + ;-Mode Game Run + Case #Mode_Game_Run + If KeyboardReleased(#PB_Key_Grave) + ;NewBonus(#Bonus_Time) + EndIf + + If KeyboardReleased(#PB_Key_Tab) + ;game\SelectedShape=8 + EndIf + + If KeyboardReleased(#PB_Key_F1) + Game\FluidCursor=1-Game\FluidCursor + EndIf + + ;Juste to test ! + CompilerIf #UsePreProdServer=#True + + If KeyboardReleased(#PB_Key_1) + ;game\SelectedShape=1 + EndIf + + If KeyboardReleased(#PB_Key_2) + ;game\SelectedShape=1 + EndIf + + If KeyboardReleased(#PB_Key_Grave) + ;PlaySound(#Snd_GetBonus) + + + ;NewBonus(#Bonus_Gravity) + ;game\SelectedShape=25 + ;DrawBitmapText(GUI\BlockSize*4,0,Str(Game\NbPiecesOnBench)) + ;Debug "C Bonus\X2Enable="+Str(Bonus\X2Enable) + EndIf + + If KeyboardReleased(#PB_Key_4) + Bonus\Remove_StartTime=ElapsedMilliseconds() + Bonus\RemoveEnable=#True + Bonus\HammerEnable=#False + EndIf + CompilerEndIf + + RunEarthQuake() + + ;Random Bonus + If ElapsedMilliseconds()-Bonus\Random_StartTime>Bonus\Random_Duration + Protected TmpBonus.l + Protected BonusValid.b=#True + Repeat + TmpBonus=Random(#Bonus_End-1,0) + Select TmpBonus + Case #Bonus_X2 + If Bonus\X2Enable>=3 + BonusValid=#False + EndIf + Case #Bonus_Eye + If Bonus\EyeEnable=#True + TmpBonus=#Bonus_Time + EndIf + Default + BonusValid=#True + EndSelect + Until BonusValid=#True + NewBonus(TmpBonus) + Bonus\Random_StartTime=ElapsedMilliseconds() + Bonus\Random_Duration=Random(20000,10000) + EndIf + + ;Add bonnus after Loop + Static DeadCounter + Static NexTimeToPutJewel.q + If LastElement(LoopPath()) And NexTimeToPutJewelGame\Difficulty(Game\ScoreData\Difficulty)\DeadBonusWaitTimer + Debug "New DEAD" + NewBonus(#Bonus_Dead) + EndIf + + ;Scroll Bonus + If Game\NbPiecesOnBench>70 And Bonus\BonusScrollDisplayed=#False + NewBonus(#Bonus_Gravity) + EndIf + + ;-Mode GameOver + Case #Mode_GameOver + + ;Remove the remaining pieces from the bench + If ElapsedMilliseconds()>Game\WaitTimer + Game\WaitTimer=ElapsedMilliseconds()+500 + Game\ToggleMode=1-Game\ToggleMode + + If Game\ToggleMode=1 + Protected Length.l + Length=SelectNextElementOnBench() + Debug "Remove Length="+Str(Length) + If Length>0 + Game\ScoreData\Score=Game\ScoreData\Score-10 + Game\UnfinishedLoopCount=Game\UnfinishedLoopCount+1 + NewMessage(Str(Game\UnfinishedLoopCount)+" Unfinished x -10 ="+Str(Game\UnfinishedLoopCount*-10),0,1000,0) + + ElseIf ListSize(MoveEngine())=0 ; IF GameOver FadeIn / FadeOut ended ! + Debug "MODE SCORE" + Game\UnfinishedLoopCount=0 + InitGameMode(#Mode_GameOver_End) ;TODO before its #Mode_CalculBonus + EndIf + Else + EraseSelectedPieceOnBench() + EndIf + EndIf + ;-Mode GameOver End +Case #Mode_GameOver_End + + Protected TmpOpacity.l=Int(ElapsedMilliseconds()/500)%255 + Game\ObjetText[8]\Opacity=TmpOpacity + + If Game\StartCalculBonus=#True And (ElapsedMilliseconds()>Game\NextTime Or KeyboardPushed(#PB_Key_Space) Or MouseButton(#PB_MouseButton_Left) ) + Game\NextTime=ElapsedMilliseconds()+200 + + ChangeText(Game\ObjetText[8],"Left Click or Espace to Speed Up") + + If Stats\Bonus_JewelBlue0 + InitGameMode(#Mode_EnterYourName) + Else + InitGameMode(#Mode_HallOfFame) + EndIf + EndIf + EndIf + + + + EndIf + ;-Mode Enter Your Name + Case #Mode_EnterYourName + + + If KeyboardReleased(#PB_Key_Back) + Game\ScoreData\Pseudo= Left(Game\ScoreData\Pseudo, Len(Game\ScoreData\Pseudo)-1) + ChangeText(Game\ObjetText[0],Game\ScoreData\Pseudo) + Else + If Len(Game\ScoreData\Pseudo)<8 + Protected text.s + CompilerIf #PB_Compiler_OS=#PB_OS_Windows + text=KeyboardInkey() + CompilerElse + text=KeyboardInkeyEx() ;Function define in Main.pb + CompilerEndIf + If FindString("1234567890'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", text) ; Ajouter vos propres caractères valides ici + Game\ScoreData\Pseudo + text + ChangeText(Game\ObjetText[0],Game\ScoreData\Pseudo) + EndIf ; Ajouter le nouveau texte à l'actuel (le cas échéant) + EndIf + EndIf + If ElapsedMilliseconds()>Game\NextTime + Game\NextTime=ElapsedMilliseconds()+500 + Game\ObjetText[0]\String=Game\ScoreData\Pseudo+"_" + Else + Game\ObjetText[0]\String=Game\ScoreData\Pseudo + EndIf + + If KeyboardReleased(#PB_Key_Return) + If Game\ScoreData\Pseudo<>"" + SaveScoreToLocalDB() + If Game\ConnectToServer=#True + SaveScoreToServerDB() + EndIf + EndIf + InitGameMode(#Mode_HallOfFame) + EndIf + ;-Mode HallOfFame + Case #Mode_HallOfFame + + If KeyboardOrMouseClick() + InitGameMode(#Mode_Menu) + EndIf + + + EndSelect + + If Game\ScoreData\Score<0:Game\ScoreData\Score=0:EndIf + + ;-WARNING SCREEN + If Game\Warning<>"" + Debug "WARNIIIIIIIIIIIINNNNNNNNNG!!!" + Protected *Obj_Sprite + Protected *Obj_Text + *Obj_Sprite=NewSprite(#Spr_BenchB,0,0,GUI\ScreenWidth,GUI\ScreenHeight,220,1,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Sprite,#Type_Sprite) + + DrawingBitmapFont(1) + *Obj_Text=NewText(1,"Warning !",(ScreenWidth()- TextBitmapWidth("Warning")) / 2,GUI\BlockSize*2,255,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + + DrawingBitmapFont(0) + + For n=1 To CountString(Game\Warning,Chr(13))+1 + text=StringField(Game\Warning,n,Chr(13)) + *Obj_Text=NewText(0,text,(ScreenWidth()- TextBitmapWidth(text)) / 2,GUI\BlockSize*3+n*GUI\BlockSize,255,#Spr_Depth_Front) + AddItemToDisplayEngine(*Obj_Text,#Type_BitmapText) + Next + Game\Warning="" + EndIf + + RunMoveEngine() + RenderingDisplayEngine() + ScreenShoot() + +EndProcedure +; IDE Options = PureBasic 6.00 LTS (Windows - x64) +; CursorPosition = 319 +; FirstLine = 302 +; Folding = -- +; EnableXP +; DPIAware \ No newline at end of file diff --git a/GameStructure.pbi b/GameStructure.pbi new file mode 100644 index 0000000..448242e --- /dev/null +++ b/GameStructure.pbi @@ -0,0 +1,478 @@ + +; Bonus Enumeration Order must be the same like #Spr_ + +Enumeration BonusType + #Bonus_Health ; Add Health + #Bonus_Time ; Slowest Time + #Bonus_EarthQuake ; Check Bench and pieces Fall + #Bonus_Dead ; All points X2 + #Bonus_JewelBlue ; + #Bonus_JewelRed ; + #Bonus_JewelGreen ; + #Bonus_Eye + #Bonus_Hammer + #Bonus_Remove + #Bonus_Gravity + #Bonus_Freeze + #Bonus_X2 ; All points X4 + #Bonus_End +EndEnumeration + + + +Enumeration Level + #Level_Novice + #Level_Normal + #Level_Hard + #Level_Madness +EndEnumeration + +Enumeration Mode + #Mode_record + #Mode_Intro + #Mode_Menu + #Mode_Options + #Mode_Graphics + #Mode_Audios + #Mode_Game_Init + #Mode_Game_Run + #Mode_Game_Wait + #Mode_GameOver + #Mode_GameOver_End + #Mode_EnterYourName + #Mode_HallOfFame + #Mode_Credits + #Mode_JukeBox +EndEnumeration + +Structure Table + Sprite.l + Selected.l + BonusOnThisCase.b +EndStructure + +Structure Difficulty + NbLife.l + Timer.l + TimerDownValue.l + WaitMissed.l + EarthQuakeTimer.l + NbPieceEarthQuake.l + DeadBonusWaitTimer.l + DeadBonusDuration.l + BonusHammerDuration.l + BonusRemoveDuration.l + NbLittlePiece.l + DeadCounter.l ; +EndStructure + +Structure HoF + Pseudo.s + Score.s + PiecesPerMinute.s + LoopsPerMinute.s + Duration.s + Id.s +EndStructure + +Structure ScoreData + Pseudo.s + Difficulty.l ;Before DifficultyMode + Score.l + Duration.l + PiecesPerMinute.f + LoopsPerMinute.f + AveragePiecesPerLoop.f + NbLoop.l + BigestLoopSize.l + Bonus_JewelBlue.l + Bonus_JewelRed.l + Bonus_JewelGreen.l + BenchIsEmpty.l + Fps_Max.l + Fps_Min.l + Resolution.s + Os.s + GameVersion.s + ComputerName.s + UserName.s + PlayerKey.s +EndStructure + + Structure Path + BX.l + BY.l + EndStructure + + Global NewList LoopPath.Path() + +Structure Game + ;DifficultyMode.l + Array Difficulty.Difficulty(#Level_Madness) + Array GameTable.Table(#MaxTableWidth+1,#MaxTableHeight+1) + BlockMouseX.l ; + BlockMouseY.l ; + FluidCursor.l ; #True or #False (not .b use .l to be compatible with Option menu) + VolumeMusic.l + VolumeSfx.l + CurrentMusic.l ; Music Id played + NextShape.l + SelectedShape.l + Mode.l ;See enumeration mode + ComeFromMode.l ;Last Mode + ToggleMode.l + LastChangeModeTimer.l + WaitTimer.l + DisplayMouse.b ; #True or #False + Timer.l + NextTime.l + + ;Server + ConnectToServer.l ;#True / #False + + ServerAddress.s + + + List Hof.Hof() + LastInsertIdLocal.l + LastInsertIdServer.l + ;Score + ScoreData.ScoreData + Life.l + Combo.l + NbPiecesOnBench.l + UnfinishedLoopCount.l + NbCross.l + + + ;Display Part + DrawMenu.b + DrawScore.b + DrawBench.b + DisplayEarthQuakeFall.b + DrawBonus.b + DrawTimer.b + DisplayMessage.b + DisplayCursor.b + + + + + ;Other + + DisplayFps.b + CaptureMouse.b + JukeBoxIndex.l + HallOfFameDifficultyMode.l + LittlePieceCounter.l + StartCalculBonus.b ; #False / #True Wait End Game Over Animation Before Calcul Bonus + Warning.s ; Contain Error et Important Message See Mode #Mode_Warning + WarningBackMode.l + *ObjetVinyl.SpriteData + *ObjetBlueJewel.SpriteData + *ObjetBlueJewelValue.TextData + *ObjetRedJewel.SpriteData + *ObjetRedJewelValue.TextData + *ObjetGreenJewel.SpriteData + *ObjetGreenJewelValue.TextData + + *ObjetText.TextData[10] +EndStructure + +Global Game.Game + + +Game\LastInsertIdLocal=13 +Game\ScoreData\Difficulty=#Level_Normal +Game\Difficulty(#Level_Novice)\NbLife=5 +Game\Difficulty(#Level_Novice)\Timer=6000 +Game\Difficulty(#Level_Novice)\TimerDownValue=20 +Game\Difficulty(#Level_Novice)\WaitMissed=3000 +Game\Difficulty(#Level_Novice)\EarthQuakeTimer=100000 +Game\Difficulty(#Level_Novice)\NbPieceEarthQuake=5 ;Max Nb Piece Fall after EarthQuake +Game\Difficulty(#Level_Novice)\DeadBonusWaitTimer=60000 +Game\Difficulty(#Level_Novice)\DeadBonusDuration=10000 +Game\Difficulty(#Level_Novice)\BonusHammerDuration=20000 +Game\Difficulty(#Level_Novice)\BonusRemoveDuration=10000 +Game\Difficulty(#Level_Novice)\NbLittlePiece=5 +Game\Difficulty(#Level_Novice)\DeadCounter=100 + + +Game\Difficulty(#Level_Normal)\NbLife=3 +Game\Difficulty(#Level_Normal)\timer=5000 +Game\Difficulty(#Level_Normal)\TimerDownValue=20 +Game\Difficulty(#Level_Normal)\WaitMissed=2000 +Game\Difficulty(#Level_Normal)\EarthQuakeTimer=60000 +Game\Difficulty(#Level_Normal)\NbPieceEarthQuake=10 ;Max Nb Piece Fall after EarthQuake +Game\Difficulty(#Level_Normal)\DeadBonusWaitTimer=45000 +Game\Difficulty(#Level_Normal)\DeadBonusDuration=20000 +Game\Difficulty(#Level_Normal)\BonusHammerDuration=10000 +Game\Difficulty(#Level_Normal)\BonusRemoveDuration=8000 +Game\Difficulty(#Level_Normal)\NbLittlePiece=4 +Game\Difficulty(#Level_Normal)\DeadCounter=60 + +Game\Difficulty(#Level_Hard)\NbLife=2 +Game\Difficulty(#Level_Hard)\timer=4200 +Game\Difficulty(#Level_Hard)\TimerDownValue=50 +Game\Difficulty(#Level_Hard)\WaitMissed=1000 +Game\Difficulty(#Level_Hard)\EarthQuakeTimer=45000 +Game\Difficulty(#Level_Hard)\NbPieceEarthQuake=15 ;Max Nb Piece Fall after EarthQuake +Game\Difficulty(#Level_Hard)\DeadBonusWaitTimer=30000 +Game\Difficulty(#Level_Hard)\DeadBonusDuration=30000 +Game\Difficulty(#Level_Hard)\BonusHammerDuration=10000 +Game\Difficulty(#Level_Hard)\BonusRemoveDuration=6000 +Game\Difficulty(#Level_Hard)\NbLittlePiece=3 +Game\Difficulty(#Level_Hard)\DeadCounter=30 + +Game\Difficulty(#Level_Madness)\NbLife=1 +Game\Difficulty(#Level_Madness)\timer=3800 +Game\Difficulty(#Level_Madness)\TimerDownValue=50 +Game\Difficulty(#Level_Madness)\WaitMissed=500 +Game\Difficulty(#Level_Madness)\EarthQuakeTimer=30000 +Game\Difficulty(#Level_Madness)\NbPieceEarthQuake=20 ;Max Nb Piece Fall after EarthQuake +Game\Difficulty(#Level_Madness)\DeadBonusWaitTimer=20000 +Game\Difficulty(#Level_Madness)\DeadBonusDuration=25000 +Game\Difficulty(#Level_Madness)\BonusHammerDuration=5000 +Game\Difficulty(#Level_Madness)\BonusRemoveDuration=4000 +Game\Difficulty(#Level_Madness)\NbLittlePiece=2 +Game\Difficulty(#Level_Madness)\DeadCounter=10 + +Structure Stats + StartGameTimer.q + StartLoopTimer.q + List PieceTime.l() + List LoopTime.l() + List NbPieces.l() + Array NbItemByGroup.l(7) + Array NbBonus.l(#Bonus_End) + ;To calcul Bonus + BigestLoopSize.l + NbLoop.l + Bonus_JewelBlue.l + Bonus_JewelRed.l + Bonus_JewelGreen.l + BenchIsEmpty.l +EndStructure + +Global Stats.Stats + +Procedure.s BoolToString(B.b) + If B=#True + ProcedureReturn "True" + Else + ProcedureReturn "False" + EndIf +EndProcedure + +Procedure.b StringToBool(String.s) + String=Trim(UCase(String)) + If String="YES" Or String="1" Or String="ENABLE" Or String="TRUE" + ProcedureReturn #True + Else + ProcedureReturn #False + EndIf +EndProcedure + +Procedure InitNewResolution() + If SelectElement(GUI\ScreenResolution(),GUI\ScreenResolutionIndex) + Debug "InitNewReoslution() Screenresolution:"+GUI\ScreenResolution() + If LCase(GUI\ScreenResolution())="auto" + If ExamineScreenModes() + While NextScreenMode() + GUI\ScreenResolutionWidth=ScreenModeWidth() + GUI\ScreenResolutionHeight=ScreenModeHeight() + GUI\ScreenResolutionDepth=ScreenModeDepth() + Wend + EndIf + + Else + GUI\ScreenResolutionWidth=Val(StringField(GUI\ScreenResolution(),1,"x")) + GUI\ScreenResolutionHeight=Val(StringField(GUI\ScreenResolution(),2,"x")) + GUI\ScreenResolutionDepth=Val(StringField(StringField(GUI\ScreenResolution(),1,"@"),3,"x")) + EndIf + EndIf + If SelectElement(GUI\WindowResolution(),GUI\WindowResolutionIndex) + GUI\WindowResolutionWidth=Val(StringField(GUI\WindowResolution(),1,"x")) + GUI\WindowResolutionHeight=Val(StringField(GUI\WindowResolution(),2,"x")) + EndIf +EndProcedure + +Procedure.s GetScreenPrint() + Protected n.l + Protected string.s="" + For n=0 To ExamineDesktops()-1 + string+DesktopName(n)+":"+DesktopWidth(n)+"x"+DesktopHeight(n)+"x"+DesktopDepth(n)+"@"+DesktopFrequency(n)+"PosX="+DesktopX(n)+"&PosY="+DesktopY(n) + Next + ProcedureReturn StringFingerprint(string, #PB_Cipher_MD5) +EndProcedure + +Procedure LoadPrefs() + + If FileSize(GetPDataDirectory("Loopz.ini"))=-1 + If CreatePreferences(GetPDataDirectory("Loopz.ini")) + Debug "LoadPrefs() Create Loopz.ini >"+GetPDataDirectory("Loopz.ini") + WritePreferenceString("FullScreen","True") + WritePreferenceString("ScreenResolution","Auto") + WritePreferenceString("VolumeMusic","70") + WritePreferenceString("VolumeSfx","100") + WritePreferenceLong("LastInsertIdServer",-1) + WritePreferenceLong("LastInsertIdLocal",-1) + WritePreferenceString ("LastPseudoUsed","") + WritePreferenceString ("PlayerKey","") + ClosePreferences() + Else + Debug "LoadPrefs() Can't Create Loopz.ini >"+GetPDataDirectory("Loopz.ini") + EndIf + EndIf + If OpenPreferences(GetPDataDirectory("Loopz.ini")) + Debug "LoadPrefs() Load Loopz.ini >"+GetPDataDirectory("Loopz.ini") + GUI\FullScreen=StringToBool(ReadPreferenceString("FullScreen","True")) + Protected.l ScreenResolution.s,WindowResolution.s + ScreenResolution=ReadPreferenceString("ScreenResolution","Auto") + Game\FluidCursor=StringToBool(ReadPreferenceString("FluidCursor","True")) + Game\VolumeMusic=Int(ReadPreferenceLong("VolumeMusic",100)/10) + Game\VolumeSfx=Int(ReadPreferenceLong("VolumeSfx",100)/10) + Game\LastInsertIdServer=ReadPreferenceLong("LastInsertIdServer",-1) + Game\LastInsertIdLocal=ReadPreferenceLong("LastInsertIdLocal",-1) + Game\ScoreData\Pseudo=ReadPreferenceString ("LastPseudoUsed","") + Game\ScoreData\PlayerKey=ReadPreferenceString ("PlayerKey","") + + ;Set Resolution + If LCase(ScreenResolution)="auto" + Protected.l SWidth,SHeight,SDepth,SFreq + + If ExamineScreenModes() + ;Select Last ScreenMode (Higer) + While NextScreenMode() + SWidth=ScreenModeWidth() + SHeight=ScreenModeHeight() + SDepth=ScreenModeDepth() + SFreq=ScreenModeRefreshRate() + Wend + EndIf + ScreenResolution=Str(SWidth)+"x"+Str(SHeight)+"x"+Str(SDepth)+"@"+Str(SFreq)+"Hz" + GUI\ScreenResolutionIndex=0 + + ;If resolution is defined Like WidthxHeightxDepth@FreqHz + Else + GUI\ScreenResolutionIndex=-1 + ;Check If resolution exist in + ForEach GUI\ScreenResolution() + If LCase(GUI\ScreenResolution())=LCase(ScreenResolution) + GUI\ScreenResolutionIndex=ListIndex(GUI\ScreenResolution()) + Break + EndIf + Next + ;If No ScreenResolution No Found + If GUI\ScreenResolutionIndex=-1 + GUI\ScreenResolutionIndex=0 + EndIf + EndIf + + If SelectElement(GUI\ScreenResolution(),GUI\ScreenResolutionIndex) + Debug "LoadPrefs() Screenresolution:"+GUI\ScreenResolution() + Else + Debug "LoadPrefs() Screenresolution:Error" + EndIf + + ;Window + PreferenceGroup("ConfigScreens:"+GetScreenPrint()) + GUI\WindowX=Val(ReadPreferenceString ("WindowX","-1" )) + GUI\WindowY=Val(ReadPreferenceString("WindowY","-1" )) + Debug "LoadPrefs() WindowX="+Str(GUI\WindowX) + Debug "LoadPrefs() WindowY="+Str(GUI\WindowY) + WindowResolution=ReadPreferenceString("WindowResolution","1024x576") + GUI\WindowResolutionIndex=-1 + ForEach GUI\WindowResolution() + If LCase(GUI\WindowResolution())=LCase(WindowResolution) + GUI\WindowResolutionIndex=ListIndex(GUI\WindowResolution()) + Break + EndIf + Next + If GUI\WindowResolutionIndex=-1 + GUI\WindowResolutionIndex=2 ; default 1024x576 + EndIf + PreferenceGroup("Server") + CompilerIf #UsePreProdServer=#True + Game\ServerAddress=#PreProdServerURL + CompilerElse + Game\ServerAddress=ReadPreferenceString ("URL","https://loopzdb.thyphoon.net/LoopzServer.php" ) + CompilerEndIf + Game\ConnectToServer=StringToBool(ReadPreferenceString ("ConnectToServer","True" )) + InitNewResolution() + ClosePreferences() + EndIf +EndProcedure + +Procedure SavePrefs() + Debug "SavePref():"+GetPDataDirectory("Loopz.ini") + If OpenPreferences(GetPDataDirectory("Loopz.ini")) + WritePreferenceString ("FullScreen", BoolToString(GUI\FullScreen)) + If SelectElement(GUI\ScreenResolution(),GUI\ScreenResolutionIndex) + WritePreferenceString ("ScreenResolution", GUI\ScreenResolution()) + Debug "SavePrefs() ScreenResolution="+GUI\ScreenResolution() + Else + Debug "ERROR: SavePrefs() GUI\ScreenResolutionIndex="+Str(GUI\ScreenResolutionIndex) + EndIf + WritePreferenceString ("FluidCursor", BoolToString(Game\FluidCursor)) + WritePreferenceLong("VolumeMusic",Game\VolumeMusic*10) + WritePreferenceLong("VolumeSfx",Game\VolumeSfx*10) + WritePreferenceLong("LastInsertIdServer",Game\LastInsertIdServer) + WritePreferenceLong("LastInsertIdLocal",Game\LastInsertIdLocal) + WritePreferenceString ("LastPseudoUsed",Game\ScoreData\Pseudo) + PreferenceGroup("ConfigScreens:"+GetScreenPrint()) + Debug "Prefs ScreenPrint:"+GetScreenPrint() + If SelectElement(GUI\WindowResolution(),GUI\WindowResolutionIndex) + WritePreferenceString ("WindowResolution", GUI\WindowResolution()) + Debug "SavePrefs() WindowResolution="+GUI\WindowResolution() + Else + Debug "ERROR: SavePrefs() GUI\WindowResolutionIndex="+Str(GUI\WindowResolutionIndex) + EndIf + WritePreferenceLong ("WindowX", GUI\WindowX) + WritePreferenceLong("WindowY", GUI\WindowY) + PreferenceGroup("Server") + WritePreferenceString ("URL",Game\ServerAddress) + WritePreferenceString ("ConnectToServer",BoolToString(Game\ConnectToServer)) + ClosePreferences() + Else + MessageRequester("Prefs Error","Can't Save "+GetPDataDirectory("Loopz.ini")) + + EndIf +EndProcedure + +;Bonus random Position +; https://stackoverflow.com/questions/196017/unique-non-repeating-random-numbers-in-o1 +#TableWidht=#MaxTableWidth+1 +#TableHeight=#MaxTableHeight+1 +#TableIndexMax=#TableWidht*#TableHeight-1 +Structure RandomUniq + Array DataList.l(#TableIndexMax) + Index.l +EndStructure +Global RandomUniq.RandomUniq + +Procedure RandUniq() + ;Randomize datas + Protected Max.l,Index.l + If RandomUniq\Index=0 + + For Max=#TableIndexMax To 0 Step -1 + Swap RandomUniq\DataList(Max),RandomUniq\DataList(Random(#TableIndexMax)) + Next + RandomUniq\Index=#TableIndexMax + EndIf + Index=RandomUniq\Index + RandomUniq\Index-1 + ProcedureReturn RandomUniq\DataList(Index) +EndProcedure + +Define n.l +For n=0 To #TableIndexMax + RandomUniq\DataList(n)=n +Next +; IDE Options = PureBasic 6.11 LTS (Windows - x64) +; CursorPosition = 398 +; FirstLine = 394 +; Folding = -- +; EnableXP +; DPIAware \ No newline at end of file diff --git a/Linux_Screen3DMousePatch.pbi b/Linux_Screen3DMousePatch.pbi new file mode 100644 index 0000000..96b7e6b --- /dev/null +++ b/Linux_Screen3DMousePatch.pbi @@ -0,0 +1,260 @@ +;-TOP +; Comment : Linux Screen3DMousePatch +; Author : mk-soft +; Version : v1.03.2 +; Create : 02.09.2022 +; Update : 10.09.2022 +; Link : https://www.purebasic.fr/english/viewtopic.php?t=79766 + +; Info: +; +; - Call InitWindowMouse after OpenScreen or OpenWindowedScreen +; - Call RestoreMouse at end of program to restore desktop mouse cursor (Needs only with OpenScreen) +; - Call FrameDelay for save cpu usage (Needs only with OpenWindowedScreen) + +; - Enumeration of cursor type: +; * Link: "https://docs.gtk.org/gdk3/enum.CursorType.html" +; * Blank: -2 +; +; - ScrollRange: +; * Auto scrolling range for mouse delta + +CompilerIf #PB_Compiler_OS = #PB_OS_Linux + + ImportC "" + gtk_widget_get_window(widget) + gdk_get_default_root_window() + gdk_window_get_cursor(window) + EndImport + + Structure udtMouseData + IsWindow.i + Window.i + WindowID.i + WindowGDK.i + IsMenu.i + CursorDefault.i + CursorScreen.i + CursorState.i + x.l + y.l + lastX.l + lastY.l + deltaX.l + deltaY.l + menuHeight.l + scrollRange.l + screenWidth.l + screenHeight.l + EndStructure + + Global MyMouseData.udtMouseData + + Procedure InitWindowMouse(Window = 0, CursorDefault = 0, CursorScreen = 130, ScrollRange = 25) + Protected PosX.l, PosY.l + With MyMouseData + ; Get Window Data + If IsWindow(Window) + \IsWindow = #True + \Window = Window + \WindowID = WindowID(Window) + \WindowGDK = gtk_widget_get_window(\WindowID) + If IsMenu(0) + \IsMenu = #True + \menuHeight = MenuHeight() + EndIf + Else + \WindowGDK = gdk_get_default_root_window() + EndIf + ; Define Cursor Data + If CursorDefault + \CursorDefault = gdk_cursor_new_(CursorDefault) + Else + \CursorDefault = gdk_window_get_cursor(\WindowGDK) + EndIf + \CursorScreen = gdk_cursor_new_(CursorScreen); Blank = -2 + gdk_window_set_cursor_(\WindowGDK, \CursorScreen) + ; Scroll Range + \scrollRange = ScrollRange + \screenWidth = ScreenWidth() + \screenHeight = ScreenHeight() + ; Get Positions + If IsWindow(Window) + gtk_widget_get_pointer_(\WindowID, @PosX, @PosY) + \lastX = PosX + \lastY = PosY + Else + \x = DesktopMouseX() + \y = DesktopMouseY() + \lastX = \x + \lastY = \y + EndIf + EndWith + ProcedureReturn #True + EndProcedure + + Procedure RestoreMouse() + Protected window, cursor + If OpenWindow(0, 0, 0, 0, 0, "Restore Mouse Cursor", #PB_Window_Invisible) + window = gdk_get_default_root_window() + cursor = gdk_cursor_new_(68) + If window + gdk_window_set_cursor_(window, cursor) + EndIf + EndIf + EndProcedure + + ; ---- + + Procedure.f MyMouseX() + ProcedureReturn MyMouseData\x + EndProcedure + + Procedure.f MyMouseY() + ProcedureReturn MyMouseData\y + EndProcedure + + Procedure.f MyMouseDeltaX() + ProcedureReturn MyMouseData\deltaX + EndProcedure + + Procedure.f MyMouseDeltaY() + ProcedureReturn MyMouseData\deltaY + EndProcedure + + Procedure MyReleaseMouse(State) + With MyMouseData + \CursorState = State + If \WindowGDK + If State + gdk_window_set_cursor_(\WindowGDK, \CursorDefault) + Else + gdk_window_set_cursor_(\WindowGDK, \CursorScreen) + EndIf + EndIf + EndWith + EndProcedure + + Procedure MyExamineMouse() + Protected PosX.l, PosY.l + + With MyMouseData + If \IsWindow + gtk_widget_get_pointer_(\WindowID, @PosX, @PosY) + If \IsMenu + PosY - \menuHeight + EndIf + If PosX < 0 + PosX = 0 + ElseIf PosX >= \screenWidth + PosX = \screenWidth - 1 + EndIf + If PosY < 0 + PosY = 0 + ElseIf PosY >= \screenHeight + PosY = \screenHeight - 1 + EndIf + Else + PosX = DesktopMouseX() + PosY = DesktopMouseY() + EndIf + + \x = PosX + \y = PosY + + If \CursorState + \deltaX = 0 + \deltaY = 0 + Else + \deltaX = PosX - \lastX + \deltaY = PosY - \lastY + EndIf + \lastX = PosX + \lastY = PosY + + If PosX < \scrollRange + \lastX = \scrollRange + If \deltaX > \scrollRange + \deltaX = \scrollRange + EndIf + ElseIf PosX > \screenWidth - \scrollRange + \lastX = \screenWidth - \scrollRange + If \deltaX < -\scrollRange + \deltaX = -\scrollRange + EndIf + Else + \lastX = PosX + EndIf + If PosY < \scrollRange + \lastY = \scrollRange + If \deltaY > \scrollRange + \deltaY = \scrollRange + EndIf + ElseIf PosY > \screenHeight - \scrollRange + \lastY = \screenHeight - \scrollRange + If \deltaY < -\scrollRange + \deltaY = -\scrollRange + EndIf + Else + \lastY = PosY + EndIf + EndWith + ProcedureReturn #True + + EndProcedure + + ;-- Macros + Macro MouseX() + MyMouseX() + EndMacro + + Macro MouseY() + MyMouseY() + EndMacro + + Macro MouseDeltaX() + MyMouseDeltaX() + EndMacro + + Macro MouseDeltaY() + MyMouseDeltaY() + EndMacro + + Macro ReleaseMouse(State) + MyReleaseMouse(State) + EndMacro + + Macro ExamineMouse() + MyExamineMouse() + EndMacro + +CompilerElse + Procedure InitWindowMouse(Window = 0, CursorDefault = 0, CursorScreen = 130, ScrollRange = 25) + ; do nothing + EndProcedure + + Procedure RestoreMouse() + ; do nothing + EndProcedure +CompilerEndIf + +Procedure FrameDelay(Frames = 30) + Static time + Protected diff_time, delay_time + If time + diff_time = ElapsedMilliseconds() - time + delay_time = (1000 / Frames) - diff_time + If delay_time > 0 + Delay(delay_time) + EndIf + EndIf + time = ElapsedMilliseconds() +EndProcedure + +;-- End +; IDE Options = PureBasic 6.00 LTS (Linux - x64) +; CursorPosition = 253 +; FirstLine = 174 +; Folding = ---- +; EnableXP +; DPIAware \ No newline at end of file diff --git a/LoopzFont.dat b/LoopzFont.dat new file mode 100644 index 0000000000000000000000000000000000000000..b7b85c686665b6c66f1751e3a5862482649175ec GIT binary patch literal 1442 zcmZ9MKS)+l7{+gDiXgTq1WJf&1Wpn<7$4MN(2#?o4#}4!v}$2U1VWUAgP5ctDg;vK z;vaBmIJA{RK_o;C?h&LzI7PoFpBFyQ3lH!4-RJ%8ea`tVxAkG+YNRKmuIfYy-9)PE zD4{u|x`PrrMylYUGbcPxOX$cvZoYe#1$7xEG-ocE_cOjwg+bjw36;&G<~{SCdA^zj zHGmTOopH}OE>hvY&iHS}{WYiOH#4rUJ?)DUiu>n%JM$YjpUU~sjNfP6!ueFr-_Q87 zInL(_=cD=H6?6Pw)try~H%NWMJY(+SJaqk~`Af$4YEJwm`?TUQnf0C|q%My8wXqg2 z+J9$WHV=|te!qFkJZrv2e)-epPv)oQKJv@oHJ>N1IP$HV*X;L_Uw-7}a&eVsuG&`@ zzc6<&D~|b(=6L=sJo&FY|H~YCACOo6fqmr_KQkYgr_5#Y%8&CqGxOTEST SERVEUR + + +CompilerSelect #PB_Compiler_OS + CompilerCase #PB_OS_Linux + CompilerSelect #PB_Compiler_Processor + CompilerCase#PB_Processor_x86 + #CompileVersion="Linuxx86" + CompilerCase#PB_Processor_x64 + #CompileVersion="Linuxx64" + CompilerCase#PB_Processor_Arm32 + #CompileVersion="LinuxArm32" + CompilerCase#PB_Processor_Arm64 + #CompileVersion="LinuxArm64" + CompilerEndSelect + CompilerCase #PB_OS_MacOS + CompilerSelect #PB_Compiler_Processor + CompilerCase#PB_Processor_x86 + #CompileVersion="MacOsx86" + CompilerCase#PB_Processor_x64 + #CompileVersion="MacOsx64" + CompilerCase#PB_Processor_Arm32 + #CompileVersion="MacOsArm32" + CompilerCase#PB_Processor_Arm64 + #CompileVersion="MacOsArm64" + CompilerEndSelect + CompilerCase #PB_OS_Windows + CompilerSelect #PB_Compiler_Processor + CompilerCase#PB_Processor_x86 + #CompileVersion="Windowsx86" + CompilerCase#PB_Processor_x64 + #CompileVersion="Windowsx64" + CompilerCase#PB_Processor_Arm32 + #CompileVersion="WindowsArm32" + CompilerCase#PB_Processor_Arm64 + #CompileVersion="WindowsArm64" + CompilerEndSelect +CompilerEndSelect + +EnableExplicit +UsePNGImageDecoder() +UsePNGImageEncoder() ; To Take ScreenShoot +UseMD5Fingerprint() + + + +;Hide cursor Code from Shardik +;src : https://www.purebasic.fr/english/viewtopic.php?f=15&t=71173&start=4 +CompilerIf #PB_Compiler_OS = #PB_OS_Linux + #GDK_BLANK_CURSOR = -2 + + ;ImportC "" + ;gtk_widget_get_window(*Widget.GtkWidget) + ;EndImport +CompilerEndIf + +Procedure HideCursor(HideCursor.I = #True) + Protected Cursor.I + + CompilerSelect #PB_Compiler_OS + CompilerCase #PB_OS_Linux + ;If HideCursor + ;; Cursor = gdk_cursor_new_(#GDK_BLANK_CURSOR) + ;Else + ; Cursor = 0 + ;EndIf + + ;gdk_window_set_cursor_(gtk_widget_get_window(WindowID(0)), Cursor) + CompilerCase #PB_OS_MacOS + If HideCursor + ;CocoaMessage(0, 0, "NSCursor hide") + Else + ;CocoaMessage(0, 0, "NSCursor unhide") + EndIf + CompilerCase #PB_OS_Windows + If HideCursor + ShowCursor_(#False) + Else + ShowCursor_(#True) + EndIf + CompilerEndSelect +EndProcedure + + +Procedure.s GetPDataDirectory(File.s) + CompilerSelect #PB_Compiler_OS + CompilerCase #PB_OS_Windows + ProcedureReturn GetUserDirectory(#PB_Directory_AllUserData)+"LoopzRemix\"+File + CompilerCase #PB_OS_MacOS + ProcedureReturn GetCurrentDirectory()+File + CompilerCase #PB_OS_Linux + ProcedureReturn GetCurrentDirectory()+File + CompilerEndSelect +EndProcedure + +Procedure.b GetLeftMouseClick() + Static Mb.l + If MouseButton(#PB_MouseButton_Left) + If Mb=#False + Debug "MOUSE 1" + Mb=#True + ProcedureReturn #True + EndIf + Else + Mb=#False + EndIf + ProcedureReturn #False + +EndProcedure +CompilerIf #PB_Compiler_OS<>#PB_OS_Windows + Procedure.s KeyboardInkeyEx() + Protected key.s + key = KeyboardInkey() + If KeyboardPushed(#PB_Key_LeftShift) Or KeyboardPushed(#PB_Key_RightShift) + key = UCase(key) + EndIf + ProcedureReturn key + EndProcedure +CompilerEndIf + + + + +;-Event GUI + +Enumeration Event + #EventGui_Empty + #EventGui_PlayJukeBox + #EventGui_ChangeVinyl + #EventGui_AddJewelBlue + #EventGui_AddJewelRed + #EventGui_AddJewelGreen + #EventGui_EnableHammer + #EventGui_EnableRemover + #EventGui_EnableEye + #EventGui_AddHealth + #EventGui_AddX2 + #EventGui_Dead + #EventGui_EnableFreeze + #EventGui_NextHallOfFame + #EventGui_NewResolution + #EventGui_ChangeMusicVolume + #EventGui_ChangeSfxVolume + #EventGui_StartCalculBonus +EndEnumeration + +Global NewList myEventGUI.l() + +Procedure PostEventGUI(Event.l) + AddElement(myEventGUI()) + myEventGUI()=Event +EndProcedure + +Procedure EventGUI() + Protected Event.l + If ListSize(myEventGUI())>0 + FirstElement(myEventGUI()) + Event=myEventGUI() + DeleteElement(myEventGUI()) + Else + Event=0 + EndIf + ProcedureReturn Event +EndProcedure + +Procedure.s MyFormatNumber(Base.s,Value.l) + Protected ValueTxt.s=Str(Value) + ProcedureReturn Left(Base,Len(Base)-Len(ValueTxt))+ValueTxt +EndProcedure + + +;- Init Library +If InitSprite() = 0 Or InitKeyboard()=0 Or InitMouse()=0 Or InitSound()=0 + MessageRequester("Erreur", "Can't Init Sprite() Or Keyboard() Or Mouse() Or Sound()", 0) + End +EndIf +Declare InitGameMode(Mode.l) +Declare AddmoveToEngine(*Value,ValueType.l,StartTime.l,Duration.l,StartValue.f,EndValue.f,Easing.l,Event.l=-1,*AutoDestroy=0) +Declare AddItemToDisplayEngine(*Pointer,Type.l,InsertIndex.l=-1) +Declare myDisplaySprite(*Sprite) +Declare DisplayText(*Text) +Declare DisplayMenu() +Declare DisplayTitles() +Declare DisplayBench() +Declare DisplayCursor() +Declare DisplayScore() +Declare DisplayMessage() +Declare DisplayBonus() +Declare DisplayEarthQuakeFall() +Declare DisplayTimer() +Declare DisplayWarning(Warning.s,BackMode.l=-1) + + +XIncludeFile("Linux_Screen3DMousePatch.pbi") +XIncludeFile("Easing.pbi") +XIncludeFile("GUI.pbi") +XIncludeFile("Package.pb") ;XIncludeFile("Package.pbi") +XIncludeFile("GameStructure.pbi") +XIncludeFile("Sprite.pbi") +XIncludeFile("SpritesObj.pbi") +XIncludeFile("BitmapText.pbi") +XIncludeFile("MoveEngine.pbi") +XIncludeFile("Sound.pbi") +XIncludeFile("Screen.pbi") +XIncludeFile("EarthQuake.pbi") +XIncludeFile("Bonus.pbi") +XIncludeFile("Database.pbi") +XIncludeFile("Shape.pbi") +XIncludeFile("Menu.pbi") +XIncludeFile("Game.pbi") +;- TEST SERVEUR +CompilerIf #TestServer=#True + ;to test server + LoadPrefs() + If OpenWindow(0, 0, 0, 640, 480, "Loopz "+#Version, #PB_Window_SystemMenu | #PB_Window_ScreenCentered) + OpenWindowedScreen(WindowID(0), 0, 0, 640, 480) +Game\ScoreData\Pseudo="Thy" +Game\ScoreData\Difficulty=1 +Game\ScoreData\Score=Random(10000,800) +Game\ScoreData\Duration=168059 +Game\ScoreData\PiecesPerMinute=27.0539970398 +Game\ScoreData\LoopsPerMinute=1.440633893 +Game\ScoreData\AveragePiecesPerLoop=16.33 +Game\ScoreData\NbLoop=3 +Game\ScoreData\BigestLoopSize=32 +Game\ScoreData\Bonus_JewelBlue=13 +Game\ScoreData\Bonus_JewelRed=1 +Game\ScoreData\BenchIsEmpty=0 +Game\ScoreData\Fps_Max=61 +Game\ScoreData\Fps_Min=60 +EndIf + +;The function you want to test +;LoadHallOfFameFromServer(1) +SaveScoreToServerDB() +End +CompilerEndIf + +Procedure Quit() + If IsDatabase(#DB) + CloseDatabase(#DB) + SavePrefs() + HideCursor(#False) + EndIf + End +EndProcedure + +Procedure DisplayWarning(Warning.s,BackMode.l=-1) + Debug Warning + If BackMode=-1 + BackMode=#Mode_Menu + EndIf + Game\Warning=Warning +EndProcedure + +Procedure Main() + ;- Load Sound + CompilerIf #UsePackFile=#True + CatchSoundFromPackage(#Snd_PutPiece,"mixkit-explainer-video-game-alert-sweep-236.wav") + CatchSoundFromPackage(#Snd_CanTPutPiece,"mixkit-video-game-retro-click-237.wav") + CatchSoundFromPackage(#Snd_DoALoop,"mixkit-extra-bonus-in-a-video-game-2045.wav") + CatchSoundFromPackage(#Snd_GetBonus,"mixkit-bonus-earned-in-video-game-2058.wav") + CatchSoundFromPackage(#Snd_GetBonus2,"322897-rhodesmas-connected-01.wav") ; https://freesound.org/people/rhodesmas/sounds/322897/ + CatchSoundFromPackage(#Snd_DeletePiece,"mixkit-fast-small-sweep-transition-166.wav") + CatchSoundFromPackage(#Snd_GetJewel,"mixkit-fairy-magic-sparkle-871.wav") + CatchSoundFromPackage(#Snd_EarthQuake,"mixkit-erupting-volcano-lava-2442.wav") + CatchSoundFromPackage(#Snd_DeadBonus,"My-Dead-Snd-Effect.wav") + CatchSoundFromPackage(#Snd_MetalHammer,"Metal-hammer.wav") + CatchSoundFromPackage(#Snd_Woosh,"Woosh 06.wav") ;old moogy73_woosh-medium-short-01.wav + CatchSoundFromPackage(#Snd_Collapse,"434897-thebuilder15-collapse.wav") + CatchSoundFromPackage(#Snd_Freeze,"446112-justinvoke-freeze.wav") + CatchSoundFromPackage(#Snd_Jukebox,"jukebox.wav") + CatchSoundFromPackage(#Snd_WaterDrop,"Goutte 03.wav") + CompilerElse + LoadSound(#Snd_PutPiece,"Datas\mixkit-explainer-video-game-alert-sweep-236.wav") ; Put piece + LoadSound(#Snd_CanTPutPiece,"Datas\mixkit-video-game-retro-click-237.wav") ; Can't put Piece + LoadSound(#Snd_DoALoop,"Datas\mixkit-extra-bonus-in-a-video-game-2045.wav") ; I Have a Loop + LoadSound(#Snd_GetBonus,"Datas\mixkit-bonus-earned-in-video-game-2058.wav") ; Get Bonus + LoadSound(#Snd_GetBonus2,"Datas\322897-rhodesmas-connected-01.wav") + LoadSound(#Snd_DeletePiece,"Datas\mixkit-fast-small-sweep-transition-166.wav") + LoadSound(#Snd_GetJewel,"Datas\mixkit-fairy-magic-sparkle-871.wav") ; Edited + LoadSound(#Snd_EarthQuake,"Datas\mixkit-erupting-volcano-lava-2442.wav") + LoadSound(#Snd_DeadBonus,"Datas\My-Dead-Snd-Effect.wav") + LoadSound(#Snd_MetalHammer,"Datas\Metal-hammer.wav") + LoadSound(#Snd_Woosh,"Datas\Woosh 06.wav") ;425706__moogy73__woosh-medium-short-01.wav + LoadSound(#Snd_WaterDrop,"Datas\Goutte 03.wav") + LoadSound(#Snd_Collapse,"Datas\434897-thebuilder15-collapse.wav") + LoadSound(#Snd_Freeze,"Datas\446112-justinvoke-freeze.wav") + LoadSound(#Snd_Jukebox,"Datas\jukebox.wav") + ;271401__ylearkisto__levyautomaatti-kolikko-aukkoon-vanha-jukebox-old-coin-into-the-slot-mechanism-starts-To-buzz.wav + + CompilerEndIf + Protected n.l=0 + For n=0 To #Snd_DeadBonus + If Not IsSound(n) + MessageRequester("Sound Error","Can't use sound "+Str(n)) + End + EndIf + Next + ;-Load Music + Game\CurrentMusic=-1 + CompilerIf #UsePackFile=#True + CatchMusicFromPackage(#Music_Intro,"Loopz03V2.mod") + CatchMusicFromPackage(#Music_GameA,"Loopz01.mod") + CatchMusicFromPackage(#Music_GameB,"Loopz02.mod") + CatchMusicFromPackage(#Music_Missed,"LoopzGameOver01.mod") + CatchMusicFromPackage(#Music_GameOver,"LoopzGameOver03.mod") + CatchMusicFromPackage(#Music_HighScore,"LoopzHighScore01V2.mod") + CatchMusicFromPackage(#Music_Credits,"Loopz10.mod") + CompilerElse + LoadMusic(#Music_Intro,"Modules/Loopz03V2.mod") + LoadMusic(#Music_GameA,"Modules/Loopz01.mod") + LoadMusic(#Music_GameB,"Modules/Loopz02.mod") + LoadMusic(#Music_Missed,"Modules/LoopzGameOver01.mod") + LoadMusic(#Music_GameOver,"Modules/LoopzGameOver03.mod") + LoadMusic(#Music_HighScore,"Modules/LoopzHighScore01V2.mod") + LoadMusic(#Music_Credits,"Modules/Loopz10.mod") + CompilerEndIf + + LoadPrefs() + + ;-Init Volume SFX / MUSIC + For n=0 To #Music_End-1 + MusicVolume(n,Game\VolumeMusic*10) + Next + + ;SoundVolume(#PB_All,Game\VolumeSfx*10) + For n=0 To #Snd_End-1 + SoundVolume(n,Game\VolumeSfx*10) + Next + + ;-Load Sprite + ; in InitScreen because you must to reload all sprite when you change resolution in game (Option resolution) + InitScreen() + Protected Event.i + InitDatabase() + InitGameMode(#Mode_Intro) + ;InitGameMode(#Mode_record) + HideCursor(#True) + MouseLocate(ScreenWidth()/2,(GUI\BenchHeight+GUI\BenchY)/2) + Protected MouseOutScreen.b=#False + Repeat + ;Loop for window Mode + If GUI\FullScreen=#False And IsWindow(0) + Repeat + Event = WindowEvent() + Select Event + Case #PB_Event_CloseWindow + Quit() + + Case #PB_Event_MoveWindow + GUI\WindowX=WindowX(0) + GUI\WindowY=WindowY(0) + + EndSelect + Until Event = 0 + EndIf + + ExamineKeyboard() + ExamineMouse() + + ;- Mouse IN/OUT + If GUI\FullScreen=#False + ;Debug "MouseOutScreen="+Str(MouseOutScreen)+" WindowMouseX(0)="+Str(WindowMouseX(0))+ " ScreenWidth()="+Str(ScreenWidth()) + If MouseOutScreen=#True And WindowMouseX(0) > 2 And WindowMouseY(0) > 2 And WindowMouseX(0) < ScreenWidth()-2 And WindowMouseY(0) < ScreenHeight() -2 + Debug "Mouse IN" + ReleaseMouse(0) + MouseLocate(WindowMouseX(0), WindowMouseY(0)) + ;MouseLocate(ScreenWidth()/2, ScreenHeight() / 2) + HideCursor(#True) + MouseOutScreen = #False + ElseIf MouseOutScreen=#False And (MouseX() <2 Or MouseY() < 2 Or MouseX() > ScreenWidth() -2 Or MouseY() > ScreenHeight() -2) + Debug "Mouse OUT" + ReleaseMouse(1) + HideCursor(#False) + MouseOutScreen = #True + EndIf + Else + MouseOutScreen=#False + ReleaseMouse(0) + EndIf + ;- Switch FullScreen / Window + If Game\Mode<>#Mode_Game_Run And KeyboardPushed(#PB_Key_LeftAlt) And KeyboardPushed(#PB_Key_Return) + DeInitScreen() + GUI\FullScreen=1-GUI\FullScreen + InitScreen() + InitGameMode(#Mode_Menu) + EndIf + + ;- Quit Game + If KeyboardReleased(#PB_Key_Escape) + If Game\Mode=#Mode_Menu + Quit() + Else + InitGameMode(#Mode_Menu) + EndIf + EndIf + If KeyboardPushed(#PB_Key_Add) + Debug Str(ElapsedMilliseconds())+ " "+Str(ListSize(MoveEngine())) + EndIf + FlipBuffersAndRetrieveFPS() + + ClearScreen(RGB(32,32,32)) + + CheckMusic() + GameMode() + If MouseOutScreen=#True + DisplayClipSprite(#Spr_White,0,0,128,1,ScreenWidth(),ScreenHeight()) + Else + If Game\DisplayCursor=#True + DisplayClipSprite(#Spr_Pointer,MouseX(),MouseY(),255,1) + EndIf + EndIf + + If Game\DisplayFps=#True + Debug Str(GUI\fpsValue)+" Fps" + EndIf + Delay(1) + ForEver +EndProcedure + +Main() +; IDE Options = PureBasic 6.11 LTS (Windows - x64) +; CursorPosition = 15 +; FirstLine = 15 +; Folding = --- +; EnableXP +; DisableDebugger +; EnableCompileCount = 158 +; EnableBuildCount = 0 +; EnableExeConstant \ No newline at end of file diff --git a/Menu.pbi b/Menu.pbi new file mode 100644 index 0000000..48232d2 --- /dev/null +++ b/Menu.pbi @@ -0,0 +1,178 @@ +Declare InitGameMode(Mode.l) + +Structure MenuOption + X.f + Y.f + Width.l + *ChoiceIndex.Long + String.s + Choices.s + GoToMode.l + SendGUIEvent.l +EndStructure + +Structure Menu + MenuTitle.s + *Obj + X.f + Y.f + Width.l + OptionIndex.l + List MenuOption.MenuOption() +EndStructure + +Global Menu.Menu + +Procedure NewMenu(MenuTitle.s,DefaultOptionIndex.l=0) + Menu\MenuTitle=MenuTitle + Menu\OptionIndex=DefaultOptionIndex + ClearList(Menu\MenuOption()) + Menu\Obj=NewSprite(-1,0,0,0,0,255,1) +EndProcedure + +Procedure AddMenuOption(String.s,GoToMode.l=-1,SendGUIEvent.l=-1,Choices.s="",*ChoiceIndex=-1) + Protected *MenuOption=AddElement(Menu\MenuOption()) + Menu\MenuOption()\String=String + Menu\MenuOption()\Choices=Choices + Menu\MenuOption()\ChoiceIndex=*ChoiceIndex + Menu\MenuOption()\GoToMode=GoToMode + Menu\MenuOption()\SendGUIEvent=SendGUIEvent + ProcedureReturn *MenuOption +EndProcedure + +Procedure StartMenu() + AddmoveToEngine(@Menu\Y,#PB_Float,0,1500,ScreenHeight(),GUI\BlockSize*2,#Easing_ElasticEaseOut) + + Protected Spacing.l,StartY.l + Spacing=((GUI\ScreenHeight-5)/ListSize(Menu\MenuOption()))*GUI\BlockSize + If Spacing>GUI\BlockSize:Spacing=GUI\BlockSize:EndIf + StartY=(ScreenHeight()-5*GUI\BlockSize-ListSize(Menu\MenuOption())*Spacing)/2 + ForEach Menu\MenuOption() + DrawingBitmapFont(0) + Protected String.s=Menu\MenuOption()\String + If Menu\MenuOption()\Choices<>"" + If Menu\MenuOption()\ChoiceIndex<>-1 + String=String+" : "+StringField(Menu\MenuOption()\Choices,Menu\MenuOption()\ChoiceIndex\l+1,"|") + Else + String=String+" Error ChoiceIndex" + EndIf + EndIf + Menu\MenuOption()\Width=TextBitmapWidth(String) + Menu\MenuOption()\X=(ScreenWidth()-Menu\MenuOption()\Width)/2 + Menu\MenuOption()\Y=3*GUI\BlockSize+StartY+ListIndex(Menu\MenuOption())*Spacing + + If ListIndex(Menu\MenuOption())%2 + AddmoveToEngine(@Menu\MenuOption()\X,#PB_Float,0,1500,ScreenWidth(),Menu\MenuOption()\X,#Easing_ElasticEaseOut) + Else + AddmoveToEngine(@Menu\MenuOption()\X,#PB_Float,0,1500,-Menu\MenuOption()\Width,Menu\MenuOption()\X,#Easing_ElasticEaseOut) + + EndIf + Next + ;StartMove(Menu\Obj) +EndProcedure + +Procedure FinalizeMenu() + DrawingBitmapFont(1) + Menu\Width=TextBitmapWidth(Menu\MenuTitle) + Menu\X=(ScreenWidth()-Menu\Width)/2 + DrawingBitmapFont(0) + StartMenu() +EndProcedure + +Procedure EndMenu(Mode.l=-1) + If Mode<>-1 + Mode=1000+Mode + EndIf + + AddmoveToEngine(@Menu\Y,#PB_Float,0,500,GUI\BlockSize*2,ScreenHeight(),#Easing_SineEaseOut,Mode) + ForEach Menu\MenuOption() + If ListIndex(Menu\MenuOption())%2 + AddmoveToEngine(@Menu\MenuOption()\X,#PB_Float,0,500,Menu\MenuOption()\X,ScreenWidth(),#Easing_SineEaseOut) + Else + + AddmoveToEngine(@Menu\MenuOption()\X,#PB_Float,0,500,Menu\MenuOption()\X,-Menu\MenuOption()\Width,#Easing_SineEaseOut) + EndIf + Next + +EndProcedure + +Procedure DisplayMenu() + Protected.l X,Y,Width,Alpha + Protected String.s + Static MB.l + DrawingBitmapFont(1) + DrawBitmapText(Menu\X,Menu\Y,Menu\MenuTitle) + DrawingBitmapFont(0) + ForEach Menu\MenuOption() + + If MouseX()>Menu\MenuOption()\X And MouseX()Menu\MenuOption()\Y And MouseY()"" + String=String+" : "+StringField(Menu\MenuOption()\Choices,Menu\MenuOption()\ChoiceIndex\l+1,"|") + EndIf + If Menu\OptionIndex=ListIndex(Menu\MenuOption()) + Alpha=255 + If GetLeftMouseClick() Or KeyboardReleased(#PB_Key_Space) ;Or (KeyboardReleased(#PB_Key_Return) And KeyboardPushed(#PB_Key_LeftAlt)=0) + PlaySound(#Snd_WaterDrop) + ;If MB=#False + ;MB=#True + If Menu\MenuOption()\Choices<>"" And Menu\MenuOption()\ChoiceIndex<>-1 + Menu\MenuOption()\ChoiceIndex\l=Menu\MenuOption()\ChoiceIndex\l+1 + If Menu\MenuOption()\ChoiceIndex\l>CountString(Menu\MenuOption()\Choices,"|") + Menu\MenuOption()\ChoiceIndex\l=0 + EndIf + Debug "Drawmenu() Space Index:"+Str(Menu\MenuOption()\ChoiceIndex\l) + ElseIf Menu\MenuOption()\GoToMode>0 + EndMenu(Menu\MenuOption()\GoToMode) + EndIf + If Menu\MenuOption()\SendGUIEvent>-1 + Debug "DrawMenu() PosteEventGUI("+Str(Menu\MenuOption()\SendGUIEvent) + PostEventGUI(Menu\MenuOption()\SendGUIEvent) + EndIf + ;EndIf + ;Else + ; MB=#False + EndIf + If Menu\MenuOption()\Choices<>"" + If KeyboardReleased(#PB_Key_Left) And Menu\MenuOption()\ChoiceIndex\l>0 + PlaySound(#Snd_WaterDrop) + Menu\MenuOption()\ChoiceIndex\l=Menu\MenuOption()\ChoiceIndex\l-1 + If Menu\MenuOption()\SendGUIEvent>-1 + PostEventGUI(Menu\MenuOption()\SendGUIEvent) + EndIf + Debug "Drawmenu() Left Index:"+Str(Menu\MenuOption()\ChoiceIndex\l) + EndIf + + If KeyboardReleased(#PB_Key_Right) And Menu\MenuOption()\ChoiceIndex\l-1 + PostEventGUI(Menu\MenuOption()\SendGUIEvent) + EndIf + Debug "Drawmenu() Right Index:"+Str(Menu\MenuOption()\ChoiceIndex\l) + EndIf + EndIf + Else + Alpha=100 + EndIf + DrawBitmapText(Menu\MenuOption()\X,Menu\MenuOption()\Y,String,Alpha) + Next + If KeyboardReleased(#PB_Key_Up) And Menu\OptionIndex>0 + PlaySound(#Snd_WaterDrop) + Menu\OptionIndex=Menu\OptionIndex-1 + EndIf + + If KeyboardReleased(#PB_Key_Down) And Menu\OptionIndexGUI\BlockSize:Spacing=GUI\BlockSize:EndIf + StartY=(ScreenHeight()-5*GUI\BlockSize-ListSize(Menu\MenuOption())*Spacing)/2 +Protected ChoiceIndex.l + ForEach Menu\MenuOption() + ChoiceIndex=1 + DrawingBitmapFont(0) + Protected String.s=Menu\MenuOption()\String + If Menu\MenuOption()\Choices<>"" + String=String+" : "+StringField(Menu\MenuOption()\Choices,ChoiceIndex+1,"|") + EndIf + Menu\MenuOption()\Width=TextBitmapWidth(String) + Menu\MenuOption()\X=(ScreenWidth()-Menu\MenuOption()\Width)/2 + Menu\MenuOption()\Y=3*GUI\BlockSize+StartY+ListIndex(Menu\MenuOption())*Spacing + + If ListIndex(Menu\MenuOption())%2 + Addmove(Menu\Obj,0,@Menu\MenuOption()\X,ScreenWidth(),Menu\MenuOption()\X,2000,#Easing_ElasticEaseOut) + Else + Addmove(Menu\Obj,0,@Menu\MenuOption()\X,-Menu\MenuOption()\Width,Menu\MenuOption()\X,2000,#Easing_ElasticEaseOut) + EndIf + Next + StartMove(Menu\Obj) +EndProcedure + +Procedure FinalizeMenu() + DrawingBitmapFont(1) + Menu\Width=TextBitmapWidth(Menu\MenuTitle) + Menu\X=(ScreenWidth()-Menu\Width)/2 + DrawingBitmapFont(0) + StartMenu() +EndProcedure + +Procedure EndMenu(Mode.l=-1) + If Mode<>-1 + Mode=1000+Mode + EndIf + Addmove(Menu\Obj,0,@Menu\Y,GUI\BlockSize*2,ScreenHeight(),2000,#Easing_ElasticEaseOut,Mode) + + ForEach Menu\MenuOption() + If ListIndex(Menu\MenuOption())%2 + Addmove(Menu\Obj,0,@Menu\MenuOption()\X,Menu\MenuOption()\X,ScreenWidth(),2000,#Easing_ElasticEaseOut) + Else + Addmove(Menu\Obj,0,@Menu\MenuOption()\X,Menu\MenuOption()\X,-Menu\MenuOption()\Width,2000,#Easing_ElasticEaseOut) + EndIf + Next + StartMove(Menu\Obj) +EndProcedure + +Procedure DrawMenu() + Protected.l X,Y,Width,Alpha,ChoiceIndex + Protected String.s + DrawingBitmapFont(1) + DrawBitmapText(Menu\X,Menu\Y,Menu\MenuTitle) + DrawingBitmapFont(0) + + + ForEach Menu\MenuOption() + String=Menu\MenuOption()\String + ChoiceIndex=1;ChoiceIndex + If Menu\MenuOption()\Choices<>"" + String=String+" : "+StringField(Menu\MenuOption()\Choices,ChoiceIndex+1,"|") + EndIf + If Menu\OptionIndex=ListIndex(Menu\MenuOption()) + Alpha=255 + If KeyboardReleased(#PB_Key_Space) + If Menu\MenuOption()\Choices<>"" + ChoiceIndex=ChoiceIndex+1 + If ChoiceIndex>CountString(Menu\MenuOption()\Choices,"|") + ChoiceIndex=0 + EndIf + + ElseIf Menu\MenuOption()\GoToMode>0 + EndMenu(Menu\MenuOption()\GoToMode) + EndIf + If Menu\MenuOption()\SendGUIEvent>-1 + PostEventGUI(Menu\MenuOption()\SendGUIEvent) + EndIf + EndIf + If Menu\MenuOption()\Choices<>"" + If KeyboardReleased(#PB_Key_Left) ;And ChoiceIndex>0 + ;TODO + ChoiceIndex=ChoiceIndex-1 + If Menu\MenuOption()\SendGUIEvent>-1 + PostEventGUI(Menu\MenuOption()\SendGUIEvent) + EndIf + EndIf + + If KeyboardReleased(#PB_Key_Right) ;And ChoiceIndex-1 + PostEventGUI(Menu\MenuOption()\SendGUIEvent) + EndIf + EndIf + EndIf + Else + Alpha=100 + EndIf + DrawBitmapText(Menu\MenuOption()\X,Menu\MenuOption()\Y,String,Alpha) + Next + If KeyboardReleased(#PB_Key_Up) And Menu\OptionIndex>0 + + Menu\OptionIndex=Menu\OptionIndex-1 + EndIf + + If KeyboardReleased(#PB_Key_Down) And Menu\OptionIndex`*>^f!SH?;eh;5+xBHLb&+z$9 zyZ;pa4qxuJ`!C^cuYI3|m*MfK-Jge7;mLlxkNTRSPu|OTA6GB$&%>+mqO;4MiHa%^6+Vr&PY17lD=SBS|_q6G0)6=G>O;4MiHa%^6+Vr&P oY17lDr%g|ro;E#gdfN1~>1or`rl(EMu70C?+Vr&PY17mG1+)OH!vFvP literal 0 HcmV?d00001 diff --git a/MoveEngine.pbi b/MoveEngine.pbi new file mode 100644 index 0000000..b6c8740 --- /dev/null +++ b/MoveEngine.pbi @@ -0,0 +1,181 @@ +Structure MoveEngine + MoveStartTime.q + StartValue.f + EndValue.f + StartTime.l + Duration.l + Easing.l + Event.l + AutoDestroySprites.b + ValueType.l ; #PB_Long / #PB_Float + *ValueL.Long; Each field (Long, Float resides at the + *ValueF.Float ; same address in memory. + + *AutoDestroy.Byte ; +EndStructure + +Global NewList MoveEngine.MoveEngine() + +Procedure AddmoveToEngine(*Value,ValueType.l,StartTime.l,Duration.l,StartValue.f,EndValue.f,Easing.l,Event.l=-1,*AutoDestroy=0) + AddElement(MoveEngine()) + MoveEngine()\ValueType=ValueType + Select MoveEngine()\ValueType + Case #PB_Long + MoveEngine()\ValueL=*Value + ;Debug "AddmoveToEngine() Long Value="+Str(*Value) + Case #PB_Float + MoveEngine()\ValueF=*Value + ;Debug "AddmoveToEngine() Float Value="+Str(*Value) + EndSelect + MoveEngine()\StartTime=StartTime + MoveEngine()\Duration=Duration + MoveEngine()\StartValue=StartValue + MoveEngine()\EndValue=EndValue + MoveEngine()\Easing=Easing + MoveEngine()\Event=Event + MoveEngine()\AutoDestroy=*AutoDestroy +EndProcedure + +Procedure RunMoveEngine() + Protected ThisStartTime.q + Protected ThisEndTime.q + Protected ElapsedTime.l + If ListSize(MoveEngine())>0 + + ForEach MoveEngine() + If MoveEngine()\MoveStartTime=0 + MoveEngine()\MoveStartTime=ElapsedMilliseconds() + EndIf + ThisStartTime=MoveEngine()\MoveStartTime+MoveEngine()\StartTime + ThisEndTime=ThisStartTime+MoveEngine()\Duration + If ElapsedMilliseconds()>=ThisStartTime And ElapsedMilliseconds()<=ThisEndTime + ElapsedTime=ElapsedMilliseconds()-ThisStartTime + If MoveEngine()\ValueL<>0 Or MoveEngine()\ValueF<>0 + Select MoveEngine()\ValueType + Case #PB_Long + MoveEngine()\ValueL\l=GetEasingPosValue(MoveEngine()\StartValue, MoveEngine()\EndValue,ThisStartTime, MoveEngine()\Duration, MoveEngine()\Easing) + Case #PB_Float + MoveEngine()\ValueF\f=GetEasingPosValue(MoveEngine()\StartValue, MoveEngine()\EndValue,ThisStartTime, MoveEngine()\Duration, MoveEngine()\Easing) + EndSelect + EndIf + ;At the End + ElseIf ElapsedMilliseconds()>=ThisEndTime + If MoveEngine()\ValueL<>0 Or MoveEngine()\ValueF<>0 + Select MoveEngine()\ValueType + Case #PB_Long + MoveEngine()\ValueL\l=MoveEngine()\EndValue + Case #PB_Float + MoveEngine()\ValueF\f=MoveEngine()\EndValue + EndSelect + EndIf + ;new Event + If MoveEngine()\Event>-1 + PostEventGUI(MoveEngine()\Event) + MoveEngine()\Event=-1 + EndIf + If MoveEngine()\AutoDestroy<>0 + MoveEngine()\AutoDestroy\b=#True + EndIf + DeleteElement(MoveEngine()) + + EndIf + Next + EndIf +EndProcedure + +Procedure ClearMoveEngine() + ClearList(MoveEngine()) +EndProcedure + +Enumeration + #Type_Sprite + #Type_BitmapText + + #Type_DisplayMenu + #Type_DisplayTitle + #Type_DisplayBench + #Type_DisplayCursor + #Type_DisplayScore + #Type_DisplayMessage + #Type_DisplayBonus + #Type_DisplayEarthQuakeFall + #Type_DisplayTimer +EndEnumeration + +Structure DisplayEngine + Type.l + *Pointer +EndStructure + +Global NewList DisplayEngine.DisplayEngine() + +Procedure RenderingDisplayEngine() + Protected *SprPointer.SpriteData + Protected *TxtPointer.TextData + ForEach DisplayEngine() + Select DisplayEngine()\Type + Case #Type_Sprite + *SprPointer=DisplayEngine()\Pointer + If *SprPointer\AutoDestroy=#True + ForEach Sprites() + If Sprites()=*SprPointer + DeleteElement(Sprites()) + Debug "DeleteElement(Sprites())" + Break; + EndIf + Next + DeleteElement(DisplayEngine()) + Debug "DeleteElement(DisplayEngine())" + Else + myDisplaySprite(DisplayEngine()\Pointer) + EndIf + Case #Type_BitmapText + *TxtPointer=DisplayEngine()\Pointer + If *TxtPointer\AutoDestroy=#True + ForEach Sprites() + If Sprites()=*TxtPointer + DeleteElement(Sprites()) + Break; + EndIf + Next + DeleteElement(DisplayEngine()) + Else + DisplayText(DisplayEngine()\Pointer) + EndIf + Case #Type_DisplayMenu + DisplayMenu() + Case #Type_DisplayTitle + DisplayTitles() + Case #Type_DisplayBench + DisplayBench() + Case #Type_DisplayCursor + DisplayCursor() + Case #Type_DisplayScore + DisplayScore() + Case #Type_DisplayMessage + DisplayMessage() + Case #Type_DisplayBonus + DisplayBonus() + Case #Type_DisplayEarthQuakeFall + DisplayEarthQuakeFall() + Case #Type_DisplayTimer + DisplayTimer() + EndSelect + Next +EndProcedure + +Procedure AddItemToDisplayEngine(*Pointer,Type.l,InsertIndex.l=-1) + AddElement(DisplayEngine()) + DisplayEngine()\Pointer=*Pointer + DisplayEngine()\Type=Type + ProcedureReturn ListIndex(DisplayEngine()) +EndProcedure + +Procedure ClearDisplayEngine() + ClearList(DisplayEngine()) +EndProcedure +; IDE Options = PureBasic 6.00 Beta 6 (Windows - x64) +; CursorPosition = 27 +; FirstLine = 18 +; Folding = -- +; EnableXP \ No newline at end of file diff --git a/MyFont.dat b/MyFont.dat new file mode 100644 index 0000000000000000000000000000000000000000..b3fe1f8b464f8da059e4a4f080a9b9f190b93399 GIT binary patch literal 1442 zcmZ9L&r4Kc6o#*5GrJZsOBcFpBeb*>Erdcy`mq`!s6_(>&aQ+aDul?O1Tm>3WH4w` z&=5n50pX((EL=!wtL%Shm4pkQH{S!}ci`pR=f3BDbI!SUdhZmD3OONV#UM)P98#P{ z3C$x#4JGssDT1$b?ePmzLVwMZ=K29Hh<=pNf_c=um2vMu4B{+GXu^EMylMVwUhL+A zxP%hg&iLXXZW7_Y%eYk9?_bThopGhSzh0D3oS)}b<{xH1o%Po<{*-YK`{}Ho%y``# z`#H{jR3E%#j`vk&Kl0xqyx*d3{`qU)pb* z7tK}rmtQqE&9mlH^e_Lh`J4HX`2zjR|7b4LuQ>X9ZGK~ajQ-`%nSYrZW>RsI9`xNO zq%4m5qdY5)-+ymjaQzsb{OI?)`M3Qh{mY*=5757O%G@@`{?5?9{P=%PWxSm6wmJ5B zp853rHJ{%ykD5tEK~M4jRqo_t%qNcb`^6mfmpNO0?CX#DCbtu+;mMEhX~!Jj!#wlK zA0{RA!#rX>!aVZtnrF;Wzh>UB-(Wt~$N5l^;OOsvhNJ&}=8+$~V!q|`PB4%Bc%Prm ex9tz%$$w&AH9s_uGmre1xr=_q_ssXr@%%2l{-1 + ProcedureReturn *Mem + Else + MessageRequester("Data Pack Error","Can't uncompress File "+FileName+" From "+PackFile) + End + EndIf + EndIf + Wend + MessageRequester("Data Pack Error","Can't Find File "+FileName+" From "+PackFile) + End + Else + MessageRequester("Data Pack Error","Can't Load File "+FileName+" From "+PackFile) + End + EndIf +EndProcedure + +Procedure.i CatchSpriteFromPackage(Sprite.i,FileName.s,PackFile.s="Datas.pck") + Protected *Mem + Protected Result.i + *Mem=ReadDataPackage(PackFile,FileName) + Result=CatchSprite(Sprite,*Mem,#PB_Sprite_AlphaBlending) + FreeMemory(*Mem) + ProcedureReturn Result +EndProcedure + +Procedure.i CatchMusicFromPackage(Music.i,FileName.s,PackFile.s="Datas.pck") + Protected *Mem + Protected Result.i + *Mem=ReadDataPackage(PackFile,FileName) + Result=CatchMusic(Music,*Mem,MemorySize(*Mem)) + FreeMemory(*Mem) + ProcedureReturn Result +EndProcedure + +Procedure.i CatchSoundFromPackage(Snd.i,FileName.s,PackFile.s="Datas.pck") + Protected *Mem + Protected Result.i + *Mem=ReadDataPackage(PackFile,FileName) + If *Mem>0 + Result=CatchSound(Snd,*Mem,MemorySize(*Mem)) + FreeMemory(*Mem) + ProcedureReturn Result + Else + MessageRequester("Error","Can't Load Pack "+PackFile+" File name "+FileName) + End + EndIf +EndProcedure + +; IDE Options = PureBasic 6.00 Beta 9 (Windows - x64) +; CursorPosition = 32 +; Folding = -- +; EnableXP \ No newline at end of file diff --git a/Screen.pbi b/Screen.pbi new file mode 100644 index 0000000..067ded6 --- /dev/null +++ b/Screen.pbi @@ -0,0 +1,155 @@ +Procedure.s GetCurrentResolution() + If GUI\FullScreen=#True + ProcedureReturn "FullScreen:"+Str(ScreenWidth())+"x"+Str(ScreenHeight()) + Else + ProcedureReturn "Window:"+Str(ScreenWidth())+"x"+Str(ScreenHeight()) + EndIf +EndProcedure + +Structure ScreenModeInfo + width.i + height.i + depth.i + hz.i +EndStructure + +Procedure InitScreen() + ExamineDesktops() + Protected.l SWidth,SHeight,SDepth + ;Fullscreen + If GUI\FullScreen=#True + ;Default Screen Resolution + If GUI\ScreenResolutionWidth=0 + If ExamineScreenModes() + NewList modes.ScreenModeInfo() + ;Select Last ScreenMode (Higer) + While NextScreenMode() + If AddElement(modes()) + modes()\width = ScreenModeWidth() + modes()\height = ScreenModeHeight() + modes()\depth = ScreenModeDepth() + modes()\hz = ScreenModeRefreshRate() + EndIf + SortStructuredList( modes(), #PB_Sort_Descending, OffsetOf(ScreenModeInfo\hz), #PB_Integer) + SortStructuredList( modes(), #PB_Sort_Descending, OffsetOf(ScreenModeInfo\width), #PB_Integer) + SortStructuredList( modes(), #PB_Sort_Descending, OffsetOf(ScreenModeInfo\height), #PB_Integer) + FirstElement(modes()) + SWidth=modes()\width + SHeight=modes()\height + SDepth=modes()\depth + Debug Str(Swidth)+"x"+Str(SHeight)+"@"+Str(Sdepth) + Wend + EndIf + End + + ;Use Screen Parameters Resolution + Else + SWidth=GUI\ScreenResolutionWidth + SHeight=GUI\ScreenResolutionHeight + SDepth=GUI\ScreenResolutionDepth + EndIf + Debug "Fullscreen:"+Str(SWidth)+"x"+Str(SHeight) + If Not OpenScreen(SWidth,SHeight,SDepth,"Loopz Remix "+#Version);,#PB_Screen_NoSynchronization + MessageRequester("Erreur", "Impossible d'ouvrir un écran "+Str(SWidth)+"x"+Str(SHeight), 0) + End + EndIf + ; Windows + Else + + ;Default Window Resolution + If GUI\WindowResolutionWidth=0 + SWidth=720*2 + SHeight=480*2 + + ;Use Window Parameters Resolution + Else + SWidth=GUI\WindowResolutionWidth + SHeight=GUI\WindowResolutionHeight + EndIf + + Debug "Window:"+Str(SWidth)+"x"+Str(SHeight) + Protected Flags.l + If GUI\WindowX<>-1 And GUI\WindowY<>-1 + Flags=#PB_Window_SystemMenu + Else + Flags=#PB_Window_SystemMenu|#PB_Window_ScreenCentered + EndIf + + If OpenWindow(0, GUI\WindowX, GUI\WindowY, DesktopUnscaledX(SWidth), DesktopUnscaledY(SHeight), "Loopz Remix "+#Version, Flags) + If Not OpenWindowedScreen(WindowID(0), 0, 0, SWidth, SHeight) + MessageRequester("Erreur", "Impossible d'ouvrir un écran dans la fenêtre!", 0) + End + EndIf + + EndIf + + EndIf + + + ;GameOriginalWidth=720 + ;GameOriginalHeight=405 + ;GameoriginalBlockWidth=32 + ;GameHigestWidth=3840 + ;GameHigestBlockHeight=128 + GUI\ScreenWidth=20 + GUI\BlockSize=ScreenWidth()/GUI\ScreenWidth + GUI\ScreenHeight=ScreenHeight()/GUI\BlockSize + GUI\HalfBlockSize=GUI\BlockSize/2 + GUI\QuarterBlockSize=GUI\BlockSize/4 + GUI\DoubleBlockSize=GUI\BlockSize*2 + + GUI\BenchWidth=(#MaxTableWidth+1)*GUI\BlockSize + GUI\BenchHeight=(#MaxTableHeight+1)*GUI\BlockSize + GUI\BenchX=(ScreenWidth()-GUI\BenchWidth)/2 + GUI\BenchY=GUI\BlockSize + + GUI\JewelBlue_X=10.5*GUI\BlockSize + GUI\JewelRed_X=13*GUI\BlockSize + + GUI\TimerWidth=GUI\BlockSize * 8 + GUI\TimerX=GUI\BenchX+(GUI\BenchWidth - GUI\TimerWidth ) /2 + GUI\TimerY=GUI\BenchY+GUI\BenchHeight+GUI\BlockSize + + LoadSpriteSheet() + CompilerIf #UsePackFile=#True + CatchBitmapFont(#Spr_FontA,"MonoFont") + CatchBitmapFont(#Spr_FontB,"LoopzFont") + CompilerElse + LoadBitmapFont(#Spr_FontA,"MonoFont") + LoadBitmapFont(#Spr_FontB,"LoopzFont") + CompilerEndIf + +EndProcedure + +Procedure DeInitScreen() + CloseScreen() + If IsWindow(0) + CloseWindow(0) + EndIf +EndProcedure + +Macro FlipBuffersAndRetrieveFPS() + Static fpsCounter + Static fpsStartTime + + If FlipBuffers() + fpsCounter + 1 + EndIf + + If (ElapsedMilliseconds()-fpsStartTime)>=1000 + GUI\fpsValue=fpsCounter + fpsCounter=0 + fpsStartTime=ElapsedMilliseconds() + If GUI\fpsValueGame\ScoreData\Fps_Max + Game\ScoreData\Fps_Max=GUI\fpsValue + EndIf + EndIf + +EndMacro +; IDE Options = PureBasic 6.00 LTS (Linux - x64) +; CursorPosition = 38 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/Shape.pbi b/Shape.pbi new file mode 100644 index 0000000..99c7e23 --- /dev/null +++ b/Shape.pbi @@ -0,0 +1,597 @@ +;-Shape +Global Dim SpGroup.l(8) + +SpGroup(0) = 239 +SpGroup(1) = SpGroup(0)+210 +SpGroup(2) = SpGroup(1)+175 +SpGroup(3) = SpGroup(2)+182 +SpGroup(4) = SpGroup(3)+85 +SpGroup(5) = SpGroup(4)+85 +SpGroup(6) = SpGroup(5)+10 +SpGroup(7) = SpGroup(6)+10 +Structure Sp + Cx.l + Cy.l + NextId.l + Array Table.l(2,2) +EndStructure + +Global Dim Sp.Sp(26) + +Procedure InitShape(Id.l,NextId.l,X.l,Y.l,A1.l=0,A2.l=0,A3.l=0,B1.l=0,B2.l=0,B3.l=0,C1.l=0,C2.l=0,C3.l=0) + Sp(Id)\NextId=NextId + Sp(Id)\Cx=X + Sp(Id)\Cy=Y + Sp(Id)\Table(0,0)=A1 + Sp(Id)\Table(1,0)=A2 + Sp(Id)\Table(2,0)=A3 + Sp(Id)\Table(0,1)=B1 + Sp(Id)\Table(1,1)=B2 + Sp(Id)\Table(2,1)=B3 + Sp(Id)\Table(0,2)=C1 + Sp(Id)\Table(1,2)=C2 + Sp(Id)\Table(2,2)=C3 +EndProcedure + + +;0 L +InitShape(0,1,0,0,#Spr_RD) +InitShape(1,2,0,0,#Spr_DL) +InitShape(2,3,0,0,#Spr_LU) +InitShape(3,0,0,0,#Spr_UR) + +;1 I +InitShape(4,5,0,0,#Spr_UD) +InitShape(5,4,0,0,#Spr_LR) + +;2 --- +InitShape(6,7,1,1,0,#Spr_UD,0,0,#Spr_UD,0,0,#Spr_UD,0) +InitShape(7,6,1,1,0,0,0,#Spr_LR,#Spr_LR,#Spr_LR) + +;3 Big L +InitShape(8,9,0,0,#Spr_RD,#Spr_LR,0,#Spr_UD) +InitShape(9,10,1,0,#Spr_LR,#Spr_DL,0,0,#Spr_UD) +InitShape(10,11,1,1,0,#Spr_UD,0,#Spr_LR,#Spr_LU) +InitShape(11,8,0,1,#Spr_UD,0,0,#Spr_UR,#Spr_LR) + + +;4 U +InitShape(12,13,1,1,0,#Spr_RD,#Spr_LR,0,#Spr_UD,0,0,#Spr_UR,#Spr_LR) +InitShape(13,14,1,1,0,0,0,#Spr_RD,#Spr_LR,#Spr_DL,#Spr_UD,0,#Spr_UD) +InitShape(14,15,1,1,#Spr_LR,#Spr_DL,0,0,#Spr_UD,0,#Spr_LR,#Spr_LU) +InitShape(15,12,1,1,#Spr_UD,0,#Spr_UD,#Spr_UR,#Spr_LR,#Spr_LU) + +;5 Z +InitShape(16,17,1,1,0,0,#Spr_UD,0,#Spr_RD,#Spr_LU,0,#Spr_UD) +InitShape(17,18,1,1,0,0,0,#Spr_LR,#Spr_DL,0,0,#Spr_UR,#Spr_LR) +InitShape(18,19,1,1,0,#Spr_UD,0,#Spr_RD,#Spr_LU,0,#Spr_UD) +InitShape(19,16,1,1,#Spr_LR,#Spr_DL,0,0,#Spr_UR,#Spr_LR) + +InitShape(20,21,1,1,#Spr_UD,0,0,#Spr_UR,#Spr_DL,0,0,#Spr_UD) +InitShape(21,22,1,1,0,#Spr_RD,#Spr_LR,#Spr_LR,#Spr_LU) +InitShape(22,23,1,1,0,#Spr_UD,0,0,#Spr_UR,#Spr_DL,0,0,#Spr_UD) +InitShape(23,20,1,1,0,0,0,0,#Spr_RD,#Spr_LR,#Spr_LR,#Spr_LU) + +;+ +InitShape(24,24,0,0,#Spr_Cross) + +;O +InitShape(25,25,0,0,#Spr_Locked) +;TODO Finish + + +Procedure DrawShape(TmpX.l,TmpY.l,Id.l,A.l=255,Scale.f=1) + + Protected Size.l=GUI\BlockSize*Scale + + Protected.l X,Y,Spr + For X=0 To 2 + For Y=0 To 2 + Spr=Sp(Id)\Table(X,Y) + If Spr>0 + DisplayClipSprite(#Spr_White,TmpX + ( X - Sp(Id)\Cx) * Size , TmpY + ( Y - Sp(Id)\Cy ) * Size,A,1,Size,Size) + DisplayClipSprite(Spr,TmpX + ( X - Sp(Id)\Cx) * Size , TmpY + ( Y - Sp(Id)\Cy ) * Size,A,1,Size,Size) + Else + ;DisplaySprite(#Spr_Cursor,TmpX + ( X - Sp(Id)\Cx) * Param\BlockSize , TmpY + ( Y - Sp(Id)\Cy ) * Param\BlockSize) + EndIf + Next + Next +EndProcedure + +Procedure.b TestShapeToBench(Bx.l,By.l,Id) + Protected X.l + Protected Y.l + Protected Sp.l + Protected TmpBx.l + Protected TmpBy.l + For X=0 To 2 + For Y=0 To 2 + Sp=Sp(Id)\Table(X,Y) + TmpBx=Bx+x-Sp(Id)\Cx + TmpBy=By+y-Sp(Id)\CY + If TmpBx>=0 And TmpBy>=0 And TmpBx<=#MaxTableWidth And TmpBy<=#MaxTableHeight + If Game\GameTable(TmpBx,TmpBy)\Sprite>0 And Sp<>0 + ProcedureReturn #False + EndIf + ElseIf Sp<>0 + ProcedureReturn #False + EndIf + Next + Next + ProcedureReturn #True +EndProcedure + +Enumeration + #Shape_None + #Shape_Up + #Shape_Down + #Shape_Left + #Shape_Right + #Shape_PosEnd +EndEnumeration + + +;Global Dim ShapeCompatible.b(#Spr_Pointer,#Shape_PosEnd,#Spr_Pointer) +;Global Dim ShapePath.l(#Spr_Pointer,#Shape_PosEnd) +CompilerIf #DebugCheckLoopVerbose=#True + Procedure.s GetDirection(Direction.l) + Select Direction + Case #Shape_None + ProcedureReturn "#Shape_None" + Case #Shape_Up + ProcedureReturn "#Shape_Up" + Case #Shape_Down + ProcedureReturn "#Shape_Down" + Case #Shape_Left + ProcedureReturn "#Shape_Left" + Case #Shape_Right + ProcedureReturn "#Shape_Right" + Case #Shape_PosEnd + ProcedureReturn "#Shape_PosEnd" + EndSelect + EndProcedure + + Procedure.s GetShapeName(Sprite.l) + Select Sprite + Case #Spr_UD + ProcedureReturn "#Spr_UD" + Case #Spr_LR + ProcedureReturn "#Spr_LR" + Case #Spr_RD + ProcedureReturn "#Spr_RD" + Case #Spr_DL + ProcedureReturn "#Spr_DL" + Case #Spr_LU + ProcedureReturn "#Spr_LU" + Case #Spr_UR + ProcedureReturn "#Spr_UR" + Case #Spr_Cross + ProcedureReturn "#Spr_Cross" + Case #Spr_Locked + ProcedureReturn "#Spr_Locked" + EndSelect + EndProcedure +CompilerEndIf + +Procedure.b InsertShapeToBench(Bx.l,By.l,Id) + Protected X.l + Protected Y.l + Protected Sp.l + Protected TmpBx.l + Protected TmpBy.l + For X=0 To 2 + For Y=0 To 2 + Sp=Sp(Id)\Table(X,Y) + TmpBx=Bx+x-Sp(Id)\Cx + TmpBy=By+y-Sp(Id)\CY + If TmpBx>=0 And TmpBy>=0 And TmpBx<=#MaxTableWidth And TmpBy<=#MaxTableHeight + If Sp>0 ;no write if empty case + Game\GameTable(TmpBx,TmpBy)\Sprite=Sp + EndIf + EndIf + Next + Next + ProcedureReturn #True +EndProcedure + +Procedure.b CheckBenchIsEmpty(SelectElement.b=#False) + Debug "CheckBenchIsEmpty()" + Protected.l Bx,By + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + If Game\GameTable(Bx,By)\Sprite>0 And Game\GameTable(Bx,By)\Selected=0 And Game\GameTable(Bx,By)\Sprite<>#Spr_Locked + Debug Str(Bx)+","+Str(By)+" Is not Empty" + ProcedureReturn #False + EndIf + Next + Next + Debug "Empty" + ProcedureReturn #True +EndProcedure +;#################################################################################### +;# New CheckLoop # +;#################################################################################### + +Procedure.l GetShapeDirection(CurrentSprite.l,InternalDirection.l) + Protected ExternalDirection.l + Select CurrentSprite + Case 0 ; no Sprite + ExternalDirection=#Shape_None + Case #Spr_UD + Select InternalDirection + Case #Shape_Down + ExternalDirection=#Shape_Down + Case #Shape_Up + ExternalDirection=#Shape_Up + Default + ExternalDirection=#Shape_None + EndSelect + Case #Spr_LR + Select InternalDirection + Case #Shape_Right + ExternalDirection=#Shape_Right + Case #Shape_Left + ExternalDirection=#Shape_Left + Default + ExternalDirection=#Shape_None + EndSelect + Case #Spr_RD + Select InternalDirection + Case #Shape_Left + ExternalDirection=#Shape_Down + Case #Shape_Up + ExternalDirection=#Shape_Right + Default + ExternalDirection=#Shape_None + EndSelect + Case #Spr_DL + Select InternalDirection + Case #Shape_Up + ExternalDirection=#Shape_Left + Case #Shape_Right + ExternalDirection=#Shape_Down + Default + ExternalDirection=#Shape_None + EndSelect + Case #Spr_LU + Select InternalDirection + Case #Shape_Down + ExternalDirection=#Shape_Left + Case #Shape_Right + ExternalDirection=#Shape_Up + Default + ExternalDirection=#Shape_None + EndSelect + Case #Spr_UR + Select InternalDirection + Case #Shape_Down + ExternalDirection=#Shape_Right + Case #Shape_Left + ExternalDirection=#Shape_Up + Default + ExternalDirection=#Shape_None + EndSelect + Case #Spr_Cross + Select InternalDirection + Case #Shape_Down + ExternalDirection=#Shape_Down + Case #Shape_Up + ExternalDirection=#Shape_Up + Case #Shape_Right + ExternalDirection=#Shape_Right + Case #Shape_Left + ExternalDirection=#Shape_Left + EndSelect + + Case #Spr_Locked + ExternalDirection=#Shape_None + EndSelect + ProcedureReturn ExternalDirection +EndProcedure + +Procedure CheckLoop(StartX.l,StartY.l,OnlyLoop.b=#True,Onepiece.b=#False) + Protected.l Bx,By + Protected.b Quit=#False + Protected.b FindLoop=#False + Protected.l InternalDirection=-1 ;#Shape_Up/#Shape_Down/#Shape_Right/#Shape_Left/#Shape_None + Protected.l CountPass.l=0 + Protected.l MaxPass.l=0 + Protected.l CurrentSprite + Protected.l CountPiece=0 + Protected.l Over=0 + Dim ReverseInternalDirection.l(4) + Dim CrossCounter.b(#MaxTableWidth,#MaxTableHeight) + NewList Path.Path() + + Debug "###### CheckLoop ######" + If OnlyLoop=#False + Debug "NO LOOP select" + EndIf + ;Init First Piece + Bx=StartX + By=StartY + Game\NbCross=0 + Repeat + + CurrentSprite=Game\GameTable(Bx,By)\Sprite + + + Debug "["+Str(Bx)+","+Str(By)+"] "+Str(CurrentSprite)+">"+GetShapeName(CurrentSprite) + + + If CrossCounter(Bx,By)=0 ;Count only One time piece like Cross + CountPiece=CountPiece+1 + AddElement(Path()) + Path()\BX=BX + Path()\BY=BY + EndIf + If CurrentSprite=#Spr_Cross And CountPass=0 + CrossCounter(Bx,By)=CrossCounter(Bx,By)+1 + Debug "CrossCounter("+Str(Bx)+","+Str(By)+")="+Str(CrossCounter(Bx,By)) + If CrossCounter(Bx,By)=2 + Game\NbCross+1 + EndIf + EndIf + + + ;Chose first Direction + If InternalDirection=-1 + Select CurrentSprite + Case 0 + InternalDirection=#Shape_None + MaxPass=0 + ReverseInternalDirection(1)=#Shape_None + Case #Spr_UD + InternalDirection=#Shape_Up + MaxPass=2 + ReverseInternalDirection(1)=#Shape_Down + Case #Spr_LR + InternalDirection=#Shape_Right + MaxPass=2 + ReverseInternalDirection(1)=#Shape_Left + Case #Spr_RD + InternalDirection=#Shape_Up + MaxPass=2 + ReverseInternalDirection(1)=#Shape_Left + Case #Spr_DL + InternalDirection=#Shape_Down + MaxPass=2 + ReverseInternalDirection(1)=#Shape_Right + Case #Spr_LU + InternalDirection=#Shape_Right + MaxPass=2 + ReverseInternalDirection(1)=#Shape_Down + Case #Spr_UR + InternalDirection=#Shape_Down + MaxPass=2 + ReverseInternalDirection(1)=#Shape_Left + Case #Spr_Cross + InternalDirection=#Shape_Up + MaxPass=4 + ReverseInternalDirection(1)=#Shape_Down + ReverseInternalDirection(2)=#Shape_Right + ReverseInternalDirection(3)=#Shape_Left + Case #Spr_Locked + ProcedureReturn #False + EndSelect + + EndIf + + InternalDirection=GetShapeDirection(CurrentSprite,InternalDirection) + + Select InternalDirection + Case #Shape_Right + Bx=Bx+1 + Case #Shape_Left + Bx=Bx-1 + Case #Shape_Up + By=By-1 + Case #Shape_Down + By=By+1 + Case #Shape_None ; No direction + + EndSelect + If Bx<0 Or By<0 Or Bx>#MaxTableWidth Or By>#MaxTableHeight + Debug "STOP OUT BENCH" + If CountPass=MaxPass" + Quit=#True + FindLoop=#False + EndIf + + + ElseIf InternalDirection=#Shape_None + Debug "STOP Bad Shape" + + + Debug "CountPass="+Str(CountPass) + If CountPass=MaxPass" + Quit=#True + FindLoop=#False + EndIf + Else + + Debug "BX="+Str(Bx)+"/"+Str(StartX)+" BY="+Str(By)+"/"+Str(StartY)+" CountPiece="+Str(CountPiece) + If Bx=StartX And By=StartY And CountPiece>2 + Debug "CrossCounter("+Str(Bx)+","+Str(By)+")="+Str(CountPiece) + Debug "MaxPass="+Str(MaxPass) + Debug "CountPass="+Str(CountPass) + If (MaxPass<>4 Or CrossCounter(Bx,By)>=2 Or CountPass=2) ; + + Debug "Find Loop on MaxPass="+Str(MaxPass)+" and CrossCounter="+Str(CrossCounter(Bx,By)) + Debug "Find Loop" + Quit=#True + FindLoop=#True + Else + Debug "NO LOOP" + EndIf + EndIf + EndIf + + ;EndIf + Over=Over+1 + If Over=250 + Debug "OVER" + End + EndIf + Until Quit=#True + + If FindLoop=#True + ForEach Path() + Game\GameTable(Path()\BX,Path()\BY)\Selected=#True + Next + ;Copy Path To LoopPath (Used to add Jewels) + CopyList(Path(),LoopPath()) + ElseIf OnlyLoop=#False + ForEach Path() + Game\GameTable(Path()\BX,Path()\BY)\Selected=#True + Next + Else + CountPiece=0 + EndIf + + ; + FreeList(Path()) + If OnlyLoop=#False + ;End + EndIf + ProcedureReturn CountPiece +EndProcedure +;#################################################################################### + + +Procedure.l SelectNextElementOnBench() + Protected Bx.l + Protected By.l + Protected Length.l + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + If Game\GameTable(Bx,By)\Sprite>0 And Game\GameTable(Bx,By)\Sprite<>#Spr_Locked + Length=CheckLoop(Bx,By,#False) + ProcedureReturn Length + EndIf + Next + Next + ProcedureReturn 0 +EndProcedure + +Procedure EraseSelectedPieceOnBench() + Protected Bx.l + Protected By.l + Protected Count.l + For By=0 To #MaxTableHeight + For Bx=0 To #MaxTableWidth + If Game\GameTable(Bx,By)\Selected=#True + Game\GameTable(Bx,By)\Sprite=0 + Game\GameTable(Bx,By)\Selected=#False + Count+1 + EndIf + Next + Next + ProcedureReturn Count +EndProcedure + +Procedure RandomShape() + Static Lastgroup.l + + + If Bonus\EyeEnable=#True + Game\SelectedShape=Game\NextShape + EndIf + + Repeat + Protected R.l + Protected Group.l + R=Random(1000) + + Protected Shape.l + Protected n.l + For n=0 To ArraySize(SpGroup())-1 + If R70 + + Game\LittlePieceCounter+1 + If Game\LittlePieceCounterLastgroup + + Lastgroup=Group + ;Add to Stats + Stats\NbItemByGroup(Group)=Stats\NbItemByGroup(Group)+1 + Select Group + Case 0 + Shape=Random(3,0) + Case 1 + Shape=Random(5,4) + Case 2 + Shape=Random(7,6) + Case 3 + Shape=Random(11,8) + Case 4 + Shape=Random(15,12) + Case 5 + Shape=Random(23,16) + Case 6 + Shape=24 + Case 7 + Shape=25 + EndSelect + + Debug "Rand="+Str(R)+" Group="+Str(Group)+" Shape="+Str(Shape) + + If Bonus\EyeEnable=#True + Game\NextShape=Shape + Else + Game\SelectedShape=Shape + EndIf + + ;First Methode + ;Param\Game\SelectedShape=Random(10,1) +EndProcedure +; IDE Options = PureBasic 6.00 LTS (Windows - x64) +; CursorPosition = 403 +; FirstLine = 534 +; Folding = --- +; EnableXP \ No newline at end of file diff --git a/Sound.pbi b/Sound.pbi new file mode 100644 index 0000000..9a1d9d0 --- /dev/null +++ b/Sound.pbi @@ -0,0 +1,76 @@ +Enumeration + #Snd_PutPiece + #Snd_CanTPutPiece + #Snd_DoALoop + #Snd_GetBonus + #Snd_GetBonus2 + #Snd_DeletePiece + #Snd_GetJewel + #Snd_EarthQuake + #Snd_DeadBonus + #Snd_MetalHammer + #Snd_WaterDrop + #Snd_Woosh + #Snd_Collapse + #Snd_Freeze + #Snd_Jukebox + #Snd_End +EndEnumeration + +Enumeration + #Music_Intro + #Music_GameA + #Music_GameB + #Music_Missed + #Music_GameOver + #Music_HighScore + #Music_Credits + #Music_End +EndEnumeration + + + + +Procedure StartMusic(Mus.l,Reset.b=#True) + If Mus<>Game\CurrentMusic + Protected n.l + For n=0 To #Music_End + If IsMusic(n):StopMusic(n):EndIf + Next + If IsMusic(Mus) + Game\CurrentMusic=Mus + + + If Reset=#True + SetMusicPosition(Mus,0) + EndIf + ;TODO remove ";" + If Game\VolumeMusic>0 + PlayMusic(Mus) + Else + Debug "NO MUS" + EndIf + EndIf +EndIf + +EndProcedure + +Procedure CheckMusic() + If Game\CurrentMusic=#Music_Missed + + If Game\Mode=#Mode_Game_Run And GetMusicPosition(#Music_Missed)=0 And GetMusicRow(#Music_Missed)>=16 + ;Debug"######################" + StopMusic(#Music_Missed) + + If Game\ScoreData\Difficulty<2 + StartMusic(#Music_GameA,#False) + Else + StartMusic(#Music_GameB,#False) + EndIf + EndIf + EndIf +EndProcedure +; IDE Options = PureBasic 6.00 LTS (Windows - x64) +; CursorPosition = 50 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/Sprite.pbi b/Sprite.pbi new file mode 100644 index 0000000..bec8ed4 --- /dev/null +++ b/Sprite.pbi @@ -0,0 +1,143 @@ +;-Sprite +Enumeration + #Spr_Black + #Spr_White + #Spr_Cursor + #Spr_SelectedBackground + #Spr_DelCursor + #Spr_BenchA + #Spr_BenchB + #Spr_BenchC + #Spr_BckgrndFadeUp + #Spr_BckgrndFadeDown + #Spr_UD + #Spr_LR + #Spr_RD + #Spr_DL + #Spr_LU + #Spr_UR + #Spr_Cross + #Spr_Locked + #Spr_Pointer + #Spr_Health + #Spr_Timer + #Spr_EarthBreak + #Spr_Dead + #Spr_JewelBlue + #Spr_JewelRed + #Spr_JewelGreen + #Spr_Eye + #Spr_Hammer + #Spr_Remove + #Spr_Gravity + #Spr_Freeze + #Spr_X2 + #Spr_X4 + #Spr_X8 + #Spr_Logo + #Spr_Sc + #Spr_Remix + #Spr_Thy + #Spr_Frozen + #Spr_Vinyl + #Spr_FontA + #Spr_FontA_End = #Spr_FontA+90 + #Spr_FontB + #Spr_FontB_End= #Spr_FontB+90 + #Spr_End +EndEnumeration + +Structure GameSprite + SpriteId.i + ClipX.l + ClipY.l + ClipWidth.l + ClipHeight.l + DisplayWidth.f + DisplayHeight.f +EndStructure + +Global Dim GameSprite.GameSprite(#Spr_End) + +Procedure RecordSprite(SpriteNo.l,SpriteId.i,ClipX.l,ClipY.l,ClipWidth.l,ClipHeight.l,DisplayWidth.f, DisplayHeight.f) + GameSprite(SpriteNo)\SpriteId=SpriteId + GameSprite(SpriteNo)\ClipX=ClipX + GameSprite(SpriteNo)\ClipY=ClipY + GameSprite(SpriteNo)\ClipWidth=ClipWidth + GameSprite(SpriteNo)\ClipHeight=ClipHeight + GameSprite(SpriteNo)\DisplayWidth=DisplayWidth + GameSprite(SpriteNo)\DisplayHeight=DisplayHeight +EndProcedure + +Procedure DisplayClipSprite(SpriteNo.i,X.l,Y.l,Opacity.l=255,GameScale.f=1,BckWidth.f=-1,BckHeight.f=-1) + + If IsSprite(GameSprite(SpriteNo)\SpriteId) + ClipSprite(GameSprite(SpriteNo)\SpriteId,GameSprite(SpriteNo)\ClipX,GameSprite(SpriteNo)\ClipY,GameSprite(SpriteNo)\ClipWidth,GameSprite(SpriteNo)\ClipHeight) + If BckWidth=-1 + BckWidth=GameSprite(SpriteNo)\DisplayWidth*GameScale*GUI\BlockSize + EndIf + If BckHeight=-1 + BckHeight=GameSprite(SpriteNo)\DisplayHeight*GameScale*GUI\BlockSize + EndIf + ZoomSprite(GameSprite(SpriteNo)\SpriteId,BckWidth,BckHeight) + DisplayTransparentSprite(GameSprite(SpriteNo)\SpriteId,X,Y,Opacity) + Else + Debug "Error with sprite" + EndIf +EndProcedure + +Procedure LoadSpriteSheet() + Protected n.l + + CompilerIf #UsePackFile=#True + CatchSpriteFromPackage(0,"SpriteSheetx192.png") + + CompilerElse + LoadSprite(0,"Datas\SpriteSheetx192.png",#PB_Sprite_AlphaBlending) + CompilerEndIf + + If IsSprite(0) + Protected SpriteSize.l=SpriteWidth(0)/10 + For n=0 To 9 + RecordSprite(#Spr_Black+n,0,n*SpriteSize,0,SpriteSize,SpriteSize,1,1) + Next + + + ;Piepeline + For n=0 To 7 + RecordSprite(#Spr_UD+n,0,n*SpriteSize,SpriteSize,SpriteSize,SpriteSize,1,1) + Next + ;Pointer + RecordSprite(#Spr_Pointer,0,8*SpriteSize,SpriteSize,SpriteSize,SpriteSize,1,1) + + ; Bonus + For n=0 To 9 + RecordSprite(#Spr_Health+n,0,n*SpriteSize,SpriteSize*2,SpriteSize,SpriteSize,1,1) + Next + + For n=0 To 5 + RecordSprite(#Spr_Gravity+n,0,n*SpriteSize,SpriteSize*3,SpriteSize,SpriteSize,1,1) + Next + + + RecordSprite(#Spr_Logo,0,0,SpriteSize*4,SpriteSize*7,SpriteSize*2,7,2) + RecordSprite(#Spr_Remix,0,0,SpriteSize*6,SpriteSize*4,SpriteSize,4,1) + RecordSprite(#Spr_Thy,0,SpriteSize*7,SpriteSize*3,SpriteSize*3,SpriteSize*3,3,3) + RecordSprite(#Spr_Frozen,0,0,SpriteSize*7,SpriteSize*8,SpriteSize,8,1) + RecordSprite(#Spr_Sc,0,0,SpriteSize*8,SpriteSize*3,SpriteSize*2,3,2) + RecordSprite(#Spr_Vinyl,0,SpriteSize*8,SpriteSize*6,SpriteSize*2,SpriteSize*4,2,4) + Else + MessageRequester("Error", "Can't Load SpriteSheet ", 0) + End + EndIf +EndProcedure + + + + + +; IDE Options = PureBasic 6.00 LTS (Windows - x64) +; CursorPosition = 117 +; FirstLine = 59 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/SpritesObj.pbi b/SpritesObj.pbi new file mode 100644 index 0000000..b341b77 --- /dev/null +++ b/SpritesObj.pbi @@ -0,0 +1,259 @@ +EnumerationBinary + #Align_Hor_Left + #Align_Hor_Middle + #Align_Hor_Right + #Align_Ver_Top + #Align_Ver_Middle + #Align_Ver_Bottom +EndEnumeration + +Structure SpriteMove + StartValue.f + EndValue.f + *Value.FLoat + StartTime.l + Duration.l + Easing.l + Event.l + AutoDestroySprites.b +EndStructure +Enumeration + #Spr_Depth_Background + #Spr_Depth_Middle + #Spr_Depth_Front + #Spr_ALL +EndEnumeration +Structure SpriteData + SpriteNo.l + X.f + Y.f + Width.f + Height.f + Opacity.f + Size.f + Align.c + Depth.l + List Move.SpriteMove() + MoveStartTime.q + AutoDestroy.b ;if #true autodestroy the sprite (From DisplayEngine()) +EndStructure + +Global NewList Sprites.SpriteData() + +Procedure.i NewSprite(SpriteNo.l,X.f,Y.f,Width.f,Height.f,Opacity.l,Size.f,Depth.l=#Spr_Depth_Front,Align.b=9) + Protected *Mem + *Mem=AddElement(Sprites()) + Sprites()\SpriteNo=SpriteNo + Sprites()\X=X + Sprites()\Y=Y + Sprites()\Width=Width + Sprites()\Height=Height + Sprites()\Opacity=Opacity + Sprites()\Size=Size + Sprites()\MoveStartTime=-1 + Sprites()\Align=Align + Sprites()\AutoDestroy=#False + Sprites()\Depth=Depth + ProcedureReturn *Mem +EndProcedure + + +Procedure _Addmove(*Sprite.SpriteData,ThisStartTime.l,*Value,StartValue.f,EndValue.f,Duration.l,Easing.l,Event.l=-1) + AddElement(*Sprite\Move()) + *Sprite\Move()\Value=*Value + *Sprite\Move()\StartTime=ThisStartTime + *Sprite\Move()\StartValue=StartValue + *Sprite\Move()\EndValue=EndValue + *Sprite\Move()\Duration=Duration + *Sprite\Move()\Easing=Easing + *Sprite\Move()\Event=Event +EndProcedure + +Procedure ClearMove(*Sprite.SpriteData) + ClearList(*Sprite\Move()) +EndProcedure + +Procedure StartMove(*Sprite.SpriteData,StartTime.q=0) + If StartTime=0 + *Sprite\MoveStartTime=ElapsedMilliseconds() + Else + *Sprite\MoveStartTime=StartTime + EndIf +EndProcedure + +Procedure StartAllMove() + Protected StartTime.q=ElapsedMilliseconds() + ForEach Sprites()\Move() + ;Sprites()\Move()\StartTime=StartTime + Next +EndProcedure + +Procedure myDisplaySprite(*Sprite.SpriteData) + ;Display + Protected X.f + Protected Y.f + Protected Width.f + Protected Height.f + Protected RealWidth.l + Protected RealHeight.l + If *Sprite\SpriteNo>0 And IsSprite(GameSprite(*Sprite\SpriteNo)\SpriteId) + ClipSprite(GameSprite(*Sprite\SpriteNo)\SpriteId,GameSprite(*Sprite\SpriteNo)\ClipX,GameSprite(*Sprite\SpriteNo)\ClipY,GameSprite(*Sprite\SpriteNo)\ClipWidth,GameSprite(*Sprite\SpriteNo)\ClipHeight) + + If *Sprite\Width<>-1 + Width=*Sprite\Width + Else + Width=GameSprite(*Sprite\SpriteNo)\DisplayWidth + EndIf + + If *Sprite\Height<>-1 + Height=*Sprite\Height + Else + Height=GameSprite(*Sprite\SpriteNo)\DisplayHeight + EndIf + + RealWidth=Width * GUI\BlockSize + RealHeight=Height * GUI\BlockSize + If Not (*Sprite\Opacity=0 Or Height=0 Or Width=0) + ZoomSprite(GameSprite(*Sprite\SpriteNo)\SpriteId,RealWidth * *Sprite\Size,RealHeight * *Sprite\Size) + + If *Sprite\Align & #Align_Hor_Left = #Align_Hor_Left + X=*Sprite\X + EndIf + + If *Sprite\Align & #Align_Hor_Middle = #Align_Hor_Middle + X=*Sprite\X-Width/2* *Sprite\Size + EndIf + + If *Sprite\Align & #Align_Hor_Right = #Align_Hor_Right + X=*Sprite\X-Width* *Sprite\Size + EndIf + + If *Sprite\Align & #Align_Ver_Top = #Align_Ver_Top + Y=*Sprite\Y + EndIf + + If *Sprite\Align & #Align_Ver_Middle=#Align_Ver_Middle + Y=*Sprite\Y-Height/2* *Sprite\Size + EndIf + If *Sprite\Align & #Align_Ver_Bottom= #Align_Ver_Bottom + Y=*Sprite\Y-Height* *Sprite\Size + EndIf + X=X * GUI\BlockSize + Y=Y * GUI\BlockSize + DisplayTransparentSprite(GameSprite(*Sprite\SpriteNo)\SpriteId,X,Y,*Sprite\Opacity) + EndIf + Else + ;Debug "Error with sprite" + EndIf +EndProcedure + +Procedure DisplaySprites(Depth.l=#Spr_ALL) + Protected SpriteNo.l + + Protected ThisStartTime.q + Protected ThisEndTime.q + Protected ElapsedTime.l + Protected AutodestroySprite.b + ForEach Sprites() + If Depth=#Spr_ALL Or Sprites()\Depth=Depth + ;Move + If Sprites()\MoveStartTime>-1 + If ListSize(Sprites()\Move())>0 + ForEach Sprites()\Move() + ThisStartTime=Sprites()\MoveStartTime+Sprites()\Move()\StartTime + ThisEndTime=ThisStartTime+Sprites()\Move()\Duration + If ElapsedMilliseconds()>=ThisStartTime And ElapsedMilliseconds()<=ThisEndTime + + ElapsedTime.l=ElapsedMilliseconds()-ThisStartTime + + Sprites()\Move()\Value\f=GetEasingPosValue(Sprites()\Move()\StartValue, Sprites()\Move()\EndValue,ThisStartTime, Sprites()\Move()\Duration, Sprites()\Move()\Easing) + ;Debug StrF(ListIndex(Sprites()\Move())) +" Value:"+StrF( Sprites()\Move()\Value\f)+" Elapestime:"+Str(ElapsedTime) + ;At the End + ElseIf ElapsedMilliseconds()>=ThisEndTime + Sprites()\Move()\Value\f=Sprites()\Move()\EndValue + ;new Event + If Sprites()\Move()\Event>-1 + PostEventGUI(Sprites()\Move()\Event) + Sprites()\Move()\Event=-1 + EndIf + DeleteElement(Sprites()\Move()) + + EndIf + Next + Else + ;AutodestroySprite=Sprites()\AutoDestroySprites + + EndIf + EndIf + + ;Display + myDisplaySprite(Sprites()) +; SpriteNo=Sprites()\SpriteNo +; If SpriteNo>0 And IsSprite(GameSprite(SpriteNo)\SpriteId) +; ClipSprite(GameSprite(SpriteNo)\SpriteId,GameSprite(SpriteNo)\ClipX,GameSprite(SpriteNo)\ClipY,GameSprite(SpriteNo)\ClipWidth,GameSprite(SpriteNo)\ClipHeight) +; +; If Sprites()\Width<>-1 +; Width=Sprites()\Width +; Else +; Width=GameSprite(SpriteNo)\DisplayWidth +; EndIf +; +; If Sprites()\Height<>-1 +; Height=Sprites()\Height +; Else +; Height=GameSprite(SpriteNo)\DisplayHeight +; EndIf +; +; RealWidth=Width * GUI\BlockSize +; RealHeight=Height * GUI\BlockSize +; If Not (Sprites()\Opacity=0 Or Height=0 Or Width=0) +; ZoomSprite(GameSprite(SpriteNo)\SpriteId,RealWidth * Sprites()\Size,RealHeight * Sprites()\Size) +; +; If Sprites()\Align & #Align_Hor_Left = #Align_Hor_Left +; X=Sprites()\X +; EndIf +; +; If Sprites()\Align & #Align_Hor_Middle = #Align_Hor_Middle +; X=Sprites()\X-Width/2* Sprites()\Size +; EndIf +; +; If Sprites()\Align & #Align_Hor_Right = #Align_Hor_Right +; X=Sprites()\X-Width* Sprites()\Size +; EndIf +; +; If Sprites()\Align & #Align_Ver_Top = #Align_Ver_Top +; Y=Sprites()\Y +; EndIf +; +; If Sprites()\Align & #Align_Ver_Middle=#Align_Ver_Middle +; Y=Sprites()\Y-Height/2* Sprites()\Size +; EndIf +; If Sprites()\Align & #Align_Ver_Bottom= #Align_Ver_Bottom +; Y=Sprites()\Y-Height* Sprites()\Size +; EndIf +; X=X * GUI\BlockSize +; Y=Y * GUI\BlockSize +; DisplayTransparentSprite(GameSprite(SpriteNo)\SpriteId,X,Y,Sprites()\Opacity) +; EndIf +; Else +; ;Debug "Error with sprite" +; EndIf + + If ListSize(Sprites()\Move())=0 And AutodestroySprite=#True + DeleteElement(Sprites()) + EndIf + EndIf + Next +EndProcedure + +Procedure ClearAllSprite() + ClearList(Sprites()) +EndProcedure + + + +; IDE Options = PureBasic 6.00 Beta 6 (Windows - x64) +; CursorPosition = 183 +; FirstLine = 134 +; Folding = -- +; EnableXP \ No newline at end of file diff --git a/ThyBitmapFontCreator.pb b/ThyBitmapFontCreator.pb new file mode 100644 index 0000000..c8d84db --- /dev/null +++ b/ThyBitmapFontCreator.pb @@ -0,0 +1,166 @@ +Structure myFontData + x.l + y.l + Width.l + Height.l +EndStructure + +Structure BitmapFont + SpriteId.i + AsciiStart.c + AsciiEnd.c + Array FontData.myFontData(1) +EndStructure + +Global NewList BitmapFont.BitmapFont() +Global Dim FinalFont.myFontData(1) +Enumeration + #Win_Main + #Gdt_Canvas + #Gdt_Marg + #Gdt_Save +EndEnumeration + + +Procedure MyLoadFont(Font.l,Name.s,Size.l,Flag=0) + Taille=1; + Img=CreateImage(#PB_Any,1,1);Creation d'une image pour travailler + Repeat + If IsFont(Font) + FreeFont(Font) + EndIf + Taille+1 + LoadFont(Font, Name, Taille,Flag) + StartDrawing(ImageOutput(Img)) + DrawingFont(FontID(Font)) + If TextHeight("@")>Size Or TextWidth("@")>Size + Taille-1 + Quit=1 + EndIf + StopDrawing() + Until Quit=1 Or Taille>500 + Debug "Taille="+Str(Taille) + FreeImage(Img) +EndProcedure + +Procedure SelectFont(*BitmapFont.BitmapFont) + Police$ = "Arial" ; Police initiale (peut aussi être nulle) + TaillePolice = 96 ; Taille initiale (peut aussi être nulle) + Resultat = FontRequester(Police$, TaillePolice, #PB_FontRequester_Effects) + If Resultat + Debug SelectedFontName() + MyLoadFont(0,SelectedFontName(),SelectedFontSize(),SelectedFontStyle()) + EndIf + *BitmapFont\AsciiStart=32 + *BitmapFont\AsciiEnd=122 + ReDim *BitmapFont\FontData(*BitmapFont\AsciiEnd-*BitmapFont\AsciiStart) + Debug "ArraySize="+Str(ArraySize(*BitmapFont\FontData())) +EndProcedure + +Procedure RefreshImage(*BitmapFont.BitmapFont,WithBorder.b=#True) + Marg=GetGadgetState(#Gdt_Marg) + If IsImage(*BitmapFont\SpriteId):FreeImage(*BitmapFont\SpriteId):EndIf + If IsFont(0) + Protected.l MaxWidth=0,MaxHeight=0 + *BitmapFont\SpriteId=CreateImage(#PB_Any,96*10,96*10,32,#PB_Image_Transparent) + StartDrawing(ImageOutput(*BitmapFont\SpriteId)) + DrawingFont(FontID(0)) + Debug "___" + Debug *BitmapFont\AsciiStart + Debug *BitmapFont\AsciiEnd + Debug "___" + For a=*BitmapFont\AsciiStart To *BitmapFont\AsciiEnd + + c=a-*BitmapFont\AsciiStart + *BitmapFont\FontData(c)\Width=TextWidth(Chr(a)) + Debug Str(a)+" width="+Str(TextWidth(Chr(a))) + *BitmapFont\FontData(c)\Height=TextHeight(Chr(a)) + If *BitmapFont\FontData(c)\Width>MaxWidth:MaxWidth=*BitmapFont\FontData(c)\Width:EndIf + If *BitmapFont\FontData(c)\Height>MaxHeight:MaxHeight=*BitmapFont\FontData(c)\Height:EndIf + Next + Debug MaxWidth + Debug MaxHeight + Else + Debug "ERRROR" + EndIf + StopDrawing() + If MaxWidth>MaxHeight + Max=MaxWidth + Else + Max=MaxHeight + EndIf + + StartDrawing(ImageOutput(*BitmapFont\SpriteId)) + DrawingFont(FontID(font)) + x.l=0:y.l=0 + ReDim FinalFont(*BitmapFont\AsciiEnd-*BitmapFont\AsciiStart) +;Dim finalFont.myFontData(90) +For a=*BitmapFont\AsciiStart To *BitmapFont\AsciiEnd + c=a-*BitmapFont\AsciiStart + + If x+*BitmapFont\FontData(c)\Width+Marg*2>ImageWidth(*BitmapFont\SpriteId) + x=0:Y=Y+MaxHeight+Marg*2 + EndIf + + If WithBorder=#True + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Outlined ) + Box(x,y,*BitmapFont\FontData(c)\Width+Marg*2,Max+Marg*2,RGBA(0,255,0,128)) + ;Line(x+Marg+*BitmapFont\FontData(c)\Width,y,1,Max,RGBA(255,0,0,200)) + EndIf + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend) + DrawText(x+Marg,y+Marg,Chr(a),RGBA(255,255,255,255)) + + finalFont(c)\x=x + finalFont(c)\y=y + finalFont(c)\Width=*BitmapFont\FontData(c)\Width+Marg*2 + finalFont(c)\Height=MaxHeight+Marg*2 + x=x+*BitmapFont\FontData(c)\Width+Marg*2 +Next +Y=Y+MaxHeight+Marg*2 +Line(0,Y,ImageWidth(*BitmapFont\SpriteId),1,RGBA(255,0,0,255)) +StopDrawing() + + + StartDrawing(CanvasOutput(#Gdt_Canvas)) + DrawImage(ImageID(*BitmapFont\SpriteId),0,0,768,768) + StopDrawing() +EndProcedure + +If OpenWindow(#Win_Main, 0, 0, 1024, 768, "Thy Font Bitmap Creator", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) + CanvasGadget(#Gdt_Canvas, 0, 0, 768, 768) + SpinGadget(#Gdt_Marg, 800, 10, 100, 25, 0,50,#PB_Spin_Numeric ) + ButtonGadget(#Gdt_Save,800,740,75,25,"Save") + *f.BitmapFont=AddElement(BitmapFont()) + SelectFont(*f) + RefreshImage(*f) + Repeat + Event = WaitWindowEvent() + + Select Event + + Case #PB_Event_Gadget + Select EventGadget() + Case #Gdt_Marg + RefreshImage(*f) + Case #Gdt_Save + RefreshImage(*f,#False) + SaveImage(BitmapFont()\SpriteId,"FontsCompress.png",#PB_ImagePlugin_ + ) +If CreateFile(0,"FontsCompress.dat") + WriteCharacter(0,BitmapFont()\AsciiStart,#PB_Ascii) + WriteCharacter(0,BitmapFont()\AsciiEnd,#PB_Ascii) + WriteData(0,@finalFont(),SizeOf(myFontData)*ArraySize(finalFont())) + CloseFile(0) +EndIf + EndSelect + + EndSelect + Until Event = #PB_Event_CloseWindow + CloseWindow(0) +EndIf + +; IDE Options = PureBasic 6.00 Beta 5 (Windows - x64) +; CursorPosition = 146 +; FirstLine = 88 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/ThyBitmapFontCreator2.pb b/ThyBitmapFontCreator2.pb new file mode 100644 index 0000000..b486613 --- /dev/null +++ b/ThyBitmapFontCreator2.pb @@ -0,0 +1,123 @@ +Structure LoadedFont + FontID.i + AsciiStart.l + AsciiEnd.l +EndStructure + +Global NewList LoadedFont.LoadedFont() + + +Structure Output + MaxSize.l + MarginTop.l + MarginRight.l + MarginBottom.l + MarginLeft.l + ImageWidth.l + ImageHeight.l +EndStructure +Global Output.Output + +Procedure MyLoadFont(Font.l,Name.s,Size.l,Flag=0) + Debug Name + Taille=1; + Img=CreateImage(#PB_Any,1,1);Creation d'une image pour travailler + Repeat + If IsFont(Font) + FreeFont(Font) + EndIf + Taille+1 + Font=LoadFont(#PB_Any, Name, Taille,Flag) + If IsFont(Font) + StartDrawing(ImageOutput(Img)) + DrawingFont(FontID(Font)) + If TextHeight("@")>Size Or TextWidth("@")>Size + Taille-1 + Quit=1 + EndIf + StopDrawing() + Else + Debug "Error Load Font "+Name + End + EndIf + Until Quit=1 Or Taille>500 + Debug "Taille="+Str(Taille) + FreeImage(Img) + ProcedureReturn Font +EndProcedure + +Procedure AddFont(Name.s,Size.l,Flag.l,AsciiStart.l,AsciiEnd.l) + AddElement(LoadedFont()) + LoadedFont()\FontID=MyLoadFont(#PB_Any,Name.s,Size.l,Flag) + LoadedFont()\AsciiStart=AsciiStart + LoadedFont()\AsciiEnd=AsciiEnd +EndProcedure + +Structure myFontData + x.l + y.l + Width.l + Height.l +EndStructure + +Procedure ExportFont(Name.s) + Protected Image.i=CreateImage(#PB_Any,Output\ImageWidth,Output\ImageHeight,32,#PB_Image_Transparent) + StartDrawing(ImageOutput(Image)) + Protected.l a,x,y,ChrWidth,MaxHeight=Output\MaxSize + Protected.c AsciiStart,AsciiEnd + FirstElement(LoadedFont()) + AsciiStart=LoadedFont()\AsciiStart + LastElement(LoadedFont()) + AsciiEnd=LoadedFont()\AsciiEnd + Debug "AsciiStart="+Str(AsciiStart) + Debug "AsciiEnd="+Str(AsciiEnd) + Dim FontData.myFontData(AsciiEnd-AsciiStart) + + ForEach LoadedFont() + ;Circle(x,y,5,RGBA(255,0,0,255)) + For a=LoadedFont()\AsciiStart To LoadedFont()\AsciiEnd + ChrWidth=Output\MarginLeft+TextWidth(Chr(a))+Output\MarginRight + If x+ChrWidth>ImageWidth(Image) + x=0:y=y+MaxHeight + EndIf + Debug Chr(a) + DrawingFont(FontID(LoadedFont()\FontID)) + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend) + FontData(a-AsciiStart)\x=x + FontData(a-AsciiStart)\y=y + FontData(a-AsciiStart)\Width=ChrWidth + FontData(a-AsciiStart)\Height=MaxHeight + DrawText(x+Output\MarginLeft,y+Output\MarginTop,Chr(a),RGBA(255,255,255,255)) + x=x+ChrWidth + Next + Next + StopDrawing() + SaveImage(Image,Name+".png",#PB_ImagePlugin_PNG) + If CreateFile(0,Name+".dat") + WriteCharacter(0,AsciiStart,#PB_Ascii) + WriteCharacter(0,AsciiEnd,#PB_Ascii) + WriteData(0,@FontData(),SizeOf(myFontData)*ArraySize(FontData())) + CloseFile(0) +EndIf +EndProcedure + +UsePNGImageEncoder() +Output\MaxSize=20 +Output\MarginTop=2 +Output\MarginBottom=2 +Output\MarginLeft=2 +Output\MarginRight=2 +Output\ImageWidth=Output\MaxSize*10 +Output\ImageHeight=Output\MaxSize*10 +Size=Output\MaxSize-Output\MarginLeft-Output\MarginRight +;AddFont("Langith RegPersonal",Size,0,32,43) +;AddFont("MonoFonto",size,0,44,59) +;AddFont("Langith RegPersonal",Size,0,60,122) +AddFont("Alton Trial",size,0,32,122) +ExportFont("AltonFont2") + +; IDE Options = PureBasic 6.00 LTS (Windows - x64) +; CursorPosition = 108 +; FirstLine = 45 +; Folding = - +; EnableXP \ No newline at end of file diff --git a/score.pbi b/score.pbi new file mode 100644 index 0000000..72766bd --- /dev/null +++ b/score.pbi @@ -0,0 +1,4 @@ + + +; IDE Options = PureBasic 6.00 Beta 6 (Windows - x64) +; EnableXP \ No newline at end of file diff --git a/test.pb b/test.pb new file mode 100644 index 0000000..c3985e7 --- /dev/null +++ b/test.pb @@ -0,0 +1,134 @@ + + +Procedure CheckLoop(StartX.l,StartY.l,OnlyLoop.b=#True,Onepiece.b=#False) + Protected OutDirection.l=-1 + Protected.l CountPass=0 + Protected.l Bx,By + NewList Path.Path() + Bx=StartX + By=StartY + Protected.l ChangeDirection=-1 + Protected.b FindLoop=#False + Protected.b EndSearch=#False + + Repeat + CurrentSprite=Game\GameTable(Bx,By)\Sprite + If CurrentSprite=0 + ProcedureReturn #False + EndIf + + ;Chose first Direction + If OutDirection=-1 + Select CurrentSprite + Case #Spr_UD + OutDirection=#Shape_Up + ChangeDirection=#Shape_Down + Case #Spr_LR + OutDirection=#Shape_Right + ChangeDirection=#Shape_Left + Case #Spr_RD + OutDirection=#Shape_Left + ChangeDirection=#Shape_Up + Case #Spr_DL + OutDirection=#Shape_Up + ChangeDirection=#Shape_Right + Case #Spr_LU + OutDirection=#Shape_Down + ChangeDirection=#Shape_Right + Case #Spr_UR + OutDirection=#Shape_Down + ChangeDirection=#Shape_Left + Case #Spr_Cross + OutDirection=#Shape_Up + ChangeDirection=#Shape_Down + Case #Spr_Locked + ProcedureReturn #False + EndSelect + + EndIf + + OutDirection=ShapeDirection(CurrentSprite,OutDirection) + + + + Select ShapeDirection + Case #Shape_Right + Bx=Bx+1 + Case #Shape_Left + Bx=Bx-1 + Case #Shape_Up + By=By-1 + Case #Shape_Down + By=By+1 + EndSelect + + If ShapeDirection=#Shape_None ;If no Way + If CountPass=0 ; If first pass I start at the beginning in reverse direction + Bx=StartX + By=StartY + OutDirection=ChangeDirection + CountPass=CountPass+1 + Else + ProcedureReturn #False + EndIf + Else + + + If Bx<0 Or By<0 Or Bx>#MaxTableWidth Or By>#MaxTableHeight + CompilerIf #DebugCheckLoopVerbose=#True:Debug"Out of GamePath "+Str(CountPiece):CompilerEndIf + OutBench=#True + EndSearch=#True + Else + NextSprite=Game\GameTable(Bx,By)\Sprite + + + If NextSprite=0 + CompilerIf #DebugCheckLoopVerbose=#True:Debug"Empty Case"+Str(CountPiece):CompilerEndIf + + EndSearch=#True + ElseIf CheckShapeCompatible(CurrentSprite,ShapeDirection,NextSprite)=#True + + ;If Back to first Piece it's a Loop + If BX=StartX And BY=StartY + If NextSprite<>#Spr_Cross Or (NextSprite=#Spr_Cross And CrossCounter(BX,BY)=2) + EndSearch=#True + FindLoop=#True + EndIf + EndIf + + EndIf + EndIf + EndIf + Until EndSearch=#True + + + Debug "OnlyLoop="+Str(OnlyLoop) + If OnlyLoop=#True + If FindLoop=#False + + CompilerIf #DebugCheckLoopVerbose=#True:Debug"Loop Stoped by bad piece"+GetShapeName(NewSprite)+" "+Str(CountPiece):CompilerEndIf + FreeList(Path()) + Debug "CheckLoop() Return #False" + ProcedureReturn #False + + EndIf + EndIf + CompilerIf #DebugCheckLoopVerbose=#True:Debug "YEeeeeeeeeeeeeeeah":CompilerEndIf + + ForEach Path() + Game\GameTable(Path()\BX,Path()\BY)\Selected=#True + Next + + CopyList(Path(),LoopPath()) + Protected LoopSize.l=ListSize(Path()) + FreeList(Path()) + CompilerIf #DebugCheckLoopVerbose=#True:Debug "Result:"+Str(LoopSize)+"/"+Str(CountPiece):CompilerEndIf + Debug "CheckLoop() Return "+Str(LoopSize) + Debug "#######" + ProcedureReturn LoopSize + + EndProcedure +; IDE Options = PureBasic 6.00 LTS (Windows - x64) +; Folding = -- +; EnableXP +; DPIAware \ No newline at end of file