114 lines
3.2 KiB
Plaintext
114 lines
3.2 KiB
Plaintext
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 |