(espace pour lancer, a pour faire tourner, flèches pour diriger)
Code : Tout sélectionner
EnableExplicit
InitSprite()
InitKeyboard()
InitSound()
Enumeration
#Step_Run
#Step_Pause
#Step_Wait
EndEnumeration
Enumeration
#MV_Down
#MV_Left
#MV_Right
EndEnumeration
Enumeration
#Blk_Empty
#Blk_I
#Blk_L
#Blk_J
#Blk_T
#Blk_S
#Blk_Z
#Blk_O
#Brick
EndEnumeration
Enumeration
#music
EndEnumeration
Declare Drawscreen()
Declare DrawBricks()
Declare DrawCurent()
Declare MakeDistri()
Declare BlockFall()
Declare CanFall()
Declare CanLeft()
Declare CanRight()
Declare CanRotate()
Declare MoveTetra(Direction)
Declare RotateTetra()
Declare CheckFullRow()
Declare FlashFullRow(List rowlist())
Declare DrawNextBlock()
Global NewList distri()
Global Dim GameZone(11,17,1), Dim Curentblock(3,1,5), Dim nextblock(3,1)
Global loop, Window,score, level, lines, font,font2, pausefont, gamestep = #Step_Wait, nextblock, LeftPushed, RightPushed, APushed, FallSpeed = 1000, Rotation
Debug CatchSound(#music,?music)
font = LoadFont(#PB_Any,"arial",30)
pausefont = LoadFont(#PB_Any,"arial",60)
font2 = LoadFont(#PB_Any,"arial",16)
Window = OpenWindow(#PB_Any,0,0,700,720,"Tetirs",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
BindEvent(#PB_Event_Timer,@BlockFall())
OpenWindowedScreen(WindowID(Window),0,0,700,720)
For loop = 0 To #Brick
CreateSprite(loop,40,40)
Next loop
DrawBricks()
For loop = 0 To 17
GameZone(0,loop,1) = #Brick
GameZone(11,loop,1) = #Brick
Next loop
Repeat
ExamineKeyboard()
Select gamestep
Case #Step_Run
If KeyboardPushed(#PB_Key_Left) And LeftPushed = 0
LeftPushed = 1
MoveTetra(#MV_Left)
EndIf
If KeyboardPushed(#PB_Key_Right) And RightPushed = 0
RightPushed = 1
MoveTetra(#MV_Right)
EndIf
If KeyboardPushed(#PB_Key_Down)
MoveTetra(#MV_Down)
EndIf
If KeyboardPushed(#PB_Key_Q) And APushed = 0
APushed = 1
RotateTetra()
EndIf
If KeyboardReleased(#PB_Key_Space)
RemoveWindowTimer(Window,0)
gamestep = #Step_Pause
EndIf
Case #Step_Pause
If KeyboardReleased(#PB_Key_Space)
AddWindowTimer(Window,0,FallSpeed)
gamestep= #Step_Run
EndIf
Case #Step_Wait
If KeyboardReleased(#PB_Key_Space)
nextblock = MakeDistri()
MakeDistri()
AddWindowTimer(Window,0,FallSpeed)
gamestep = #Step_Run
PlaySound(#music,#PB_Sound_Loop)
EndIf
EndSelect
If KeyboardReleased(#PB_Key_Left) : LeftPushed = 0 : EndIf
If KeyboardReleased(#PB_Key_Right) : RightPushed = 0 : EndIf
If KeyboardReleased(#PB_Key_Q) : APushed = 0 : EndIf
Drawscreen()
Delay(1)
Until WindowEvent() = #PB_Event_CloseWindow
Procedure DrawBricks()
StartDrawing(SpriteOutput(#Blk_Empty))
Box(0,0,40,40,$CCFFFF)
StopDrawing()
StartDrawing(SpriteOutput(#Blk_I))
Box(0,0,40,40,$339900)
Box(26,0,6,6,$003300)
Box(12,6,6,6,$003300)
Box(34,6,6,6,$003300)
Box(0,18,6,6,$003300)
Box(26,18,6,6,$003300)
Box(34,24,6,6,$003300)
Box(6,34,6,6,$003300)
Box(18,34,6,6,$003300)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,40,40,$000001)
StopDrawing()
StartDrawing(SpriteOutput(#Blk_J))
Box(0,0,40,40,$006600)
Box(10,10,20,20,$CCFFFF)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,40,40,$000001)
Box(10,10,20,20,$000001)
StopDrawing()
StartDrawing(SpriteOutput(#Blk_L))
Box(0,0,40,40,$006600)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,40,40,$000001)
StopDrawing()
StartDrawing(SpriteOutput(#Blk_S))
Box(0,0,40,40,$003300)
Box(10,10,20,20,$CCFFFF)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,40,40,$000001)
Box(10,10,20,20,$000001)
StopDrawing()
StartDrawing(SpriteOutput(#Blk_T))
Box(0,0,40,40,$006633)
Box(10,10,20,5,$CCCCCC)
Box(10,10,5,20,$CCCCCC)
Box(10,25,20,5,$000001)
Box(25,15,5,15,$000001)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,40,40,$000001)
StopDrawing()
StartDrawing(SpriteOutput(#Blk_Z))
Box(0,0,40,40,$006633)
Box(15,15,10,10,$000001)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,40,40,$000001)
StopDrawing()
StartDrawing(SpriteOutput(#Blk_O))
Box(0,0,40,40,$CCFFFF)
Box(5,5,30,30,$000001)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0,0,40,40,$000001)
StopDrawing()
StartDrawing(SpriteOutput(#Brick))
Box(0,6,16,12,$99CCCC) : Box(20,6,16,12,$99CCCC)
Box(0,25,4,12,$99CCCC) : Box(8,25,16,12,$99CCCC) : Box(28,25,12,12,$99CCCC)
StopDrawing()
EndProcedure
Procedure DrawCurent()
DisplaySprite(Curentblock(0,0,5),Curentblock(0,0,0)*40,Curentblock(0,1,0)*40)
DisplaySprite(Curentblock(0,0,5),Curentblock(1,0,0)*40,Curentblock(1,1,0)*40)
DisplaySprite(Curentblock(0,0,5),Curentblock(2,0,0)*40,Curentblock(2,1,0)*40)
DisplaySprite(Curentblock(0,0,5),Curentblock(3,0,0)*40,Curentblock(3,1,0)*40)
DrawNextBlock()
EndProcedure
Procedure DrawNextBlock()
Select nextblock
Case #Blk_I
nextblock(0,0) = 2 : nextblock(1,0) = 2 : nextblock(2,0) = 2 : nextblock(3,0) = 2
nextblock(0,1) = 0 : nextblock(1,1) = 1 : nextblock(2,1) = 2 : nextblock(3,1) = 3
Case #Blk_J
nextblock(0,0) = 2 : nextblock(1,0) = 2 : nextblock(2,0) = 2 : nextblock(3,0) = 1
nextblock(0,1) = 0 : nextblock(1,1) = 2 : nextblock(2,1) = 1 : nextblock(3,1) = 2
Case #Blk_L
nextblock(0,0) = 2 : nextblock(1,0) = 2 : nextblock(2,0) = 2 : nextblock(3,0) = 3
nextblock(0,1) = 0 : nextblock(1,1) = 2 : nextblock(2,1) = 1 : nextblock(3,1) = 2
Case #Blk_O
nextblock(0,0) = 2 : nextblock(1,0) = 3 : nextblock(2,0) = 2 : nextblock(3,0) = 3
nextblock(0,1) = 1 : nextblock(1,1) = 1 : nextblock(2,1) = 2 : nextblock(3,1) = 2
Case #Blk_S
nextblock(0,0) = 1 : nextblock(1,0) = 2 : nextblock(2,0) = 2 : nextblock(3,0) = 3
nextblock(0,1) = 2 : nextblock(1,1) = 2 : nextblock(2,1) = 1 : nextblock(3,1) = 1
Case #Blk_T
nextblock(0,0) = 1 : nextblock(1,0) = 2 : nextblock(2,0) = 3 : nextblock(3,0) = 2
nextblock(0,1) = 1 : nextblock(1,1) = 1 : nextblock(2,1) = 1 : nextblock(3,1) = 2
Case #Blk_Z
nextblock(0,0) = 1 : nextblock(1,0) = 2 : nextblock(2,0) = 2 : nextblock(3,0) = 3
nextblock(0,1) = 1 : nextblock(1,1) = 1 : nextblock(2,1) = 2 : nextblock(3,1) = 2
EndSelect
DisplaySprite(nextblock,510 + 40*nextblock(0,0),495+40*nextblock(0,1))
DisplaySprite(nextblock,510 + 40*nextblock(1,0),495+40*nextblock(1,1))
DisplaySprite(nextblock,510 + 40*nextblock(2,0),495+40*nextblock(2,1))
DisplaySprite(nextblock,510 + 40*nextblock(3,0),495+40*nextblock(3,1))
EndProcedure
Procedure Drawscreen()
Protected loopx, loopy
ClearScreen($200000)
For loopx = 0 To 11
For loopy = 0 To 17
DisplaySprite(GameZone(loopx,loopy,1),loopx * 40, loopy * 40)
Next loopy
Next loopx
StartDrawing(ScreenOutput())
Box(480,100,220,110,$CCFFFF)
Box(480,105,220,45,$003000)
Box(480,155,220,5,$003000)
Box(480,200,220,5,$003000)
Box(500,70,180,60,$CCFFFF)
Box(500,250,180,100,$CCFFFF)
Box(500,360,180,100,$CCFFFF)
Box(530,490,165,165,$CCFFFF)
DrawingMode(#PB_2DDrawing_Outlined)
Box(505,75,170,50,$003000)
Box(505,255,170,90,$003000)
Box(505,365,170,90,$003000)
Box(535,495,155,155,$003000)
DrawingFont(FontID(font))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(515,80,"SCORE",$200000)
DrawText(530,255,"LEVEL",$200000)
DrawText(530,365,"LINES",$200000)
DrawText(515,158,Str(score),$200000)
DrawText(600,300,Str(level),$200000)
DrawText(600,410,Str(lines),$200000)
StopDrawing()
If gamestep = #Step_Run
DrawCurent()
ElseIf gamestep = #Step_Pause
StartDrawing(ScreenOutput())
DrawingFont(FontID(pausefont))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(110,250,"PAUSE",$006633)
DrawingFont(FontID(font))
DrawText(80,350,"Press space to run",$006633)
StopDrawing()
Else
StartDrawing(ScreenOutput())
DrawingFont(FontID(pausefont))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(240-TextWidth("TETIRS")/2,250,"TETIRS",$006633)
DrawingFont(FontID(font))
DrawText(240-TextWidth("Press space to start !")/2,350,"Press space to start !",$006633)
DrawingFont(FontID(font2))
DrawText(240-TextWidth("Q for block rotation")/2,430,"Q for block rotation",$006633)
DrawText(240-TextWidth("Use arrow to move block")/2,450,"Use arrow to move block",$006633)
StopDrawing()
EndIf
FlipBuffers()
EndProcedure
Procedure MakeDistri()
Protected result
If ListSize(distri()) = 0
For loop = 1 To 7
AddElement(distri())
distri() = loop
Next loop
EndIf
SelectElement(distri(),Random(ListSize(distri())-1))
result = distri()
DeleteElement(distri())
If nextblock
Curentblock(0,0,5) = nextblock : Curentblock(1,0,5) = nextblock : Curentblock(2,0,5) = nextblock : Curentblock(3,0,5) = nextblock
Select nextblock ;{
Case #Blk_I
Curentblock(0,0,0) = 5 : Curentblock(3,0,0) = 5 : Curentblock(2,0,0) = 5 : Curentblock(1,0,0) = 5
Curentblock(0,0,1) = 1 : Curentblock(2,0,1) = -1 : Curentblock(1,0,1) = -2
Curentblock(0,0,2) = -1 : Curentblock(2,0,2) = 1 : Curentblock(1,0,2) = 2
Curentblock(0,0,3) = 1 : Curentblock(2,0,3) = -1 : Curentblock(1,0,3) = -2
Curentblock(0,0,4) = -1 : Curentblock(2,0,4) = 1 : Curentblock(1,0,4) = 2
Curentblock(0,1,0) = -4 : Curentblock(3,1,0) = -3 : Curentblock(2,1,0) = -2 : Curentblock(1,1,0) = -1
Curentblock(0,1,1) = 1 : Curentblock(2,1,1) = -1 : Curentblock(1,1,1) = -2
Curentblock(0,1,2) = -1 : Curentblock(2,1,2) = 1 : Curentblock(1,1,2) = 2
Curentblock(0,1,3) = 1 : Curentblock(2,1,3) = -1 : Curentblock(1,1,3) = -2
Curentblock(0,1,4) = -1 : Curentblock(2,1,4) = 1 : Curentblock(1,1,4) = 2
Case #Blk_J
Curentblock(0,0,0) = 5 : Curentblock(3,0,0) = 5 : Curentblock(2,0,0) = 5 : Curentblock(1,0,0) = 4
Curentblock(0,0,1) = -2 : Curentblock(2,0,1) = -1 : Curentblock(1,0,1) = 1
Curentblock(0,0,2) = 2 : Curentblock(2,0,2) = 1 : Curentblock(1,0,2) = 1
Curentblock(0,0,3) = 2 : Curentblock(2,0,3) = 1 : Curentblock(1,0,3) = -1
Curentblock(0,0,4) = -2 : Curentblock(2,0,4) = -1 : Curentblock(1,0,4) = -1
Curentblock(0,1,0) = -3 : Curentblock(3,1,0) = -1 : Curentblock(2,1,0) = -2 : Curentblock(1,1,0) = -1
Curentblock(0,1,1) = 2 : Curentblock(2,1,1) = 1 : Curentblock(1,1,1) = 1
Curentblock(0,1,2) = 2 : Curentblock(2,1,2) = 1 : Curentblock(1,1,2) = -1
Curentblock(0,1,3) = -2 : Curentblock(2,1,3) = -1 : Curentblock(1,1,3) = -1
Curentblock(0,1,4) = -2 : Curentblock(2,1,4) =- 1 : Curentblock(1,1,4) = 1
Case #Blk_L
Curentblock(0,0,0) = 5 : Curentblock(3,0,0) = 5 : Curentblock(2,0,0) = 5 : Curentblock(1,0,0) = 6
Curentblock(0,0,1) = -2 : Curentblock(2,0,1) = -1 : Curentblock(1,0,1) = -1
Curentblock(0,0,2) = 2 : Curentblock(2,0,2) = 1 : Curentblock(1,0,2) = -1
Curentblock(0,0,3) = 2 : Curentblock(2,0,3) = 1 : Curentblock(1,0,3) = 1
Curentblock(0,0,4) = -2 : Curentblock(2,0,4) = -1 : Curentblock(1,0,4) = 1
Curentblock(0,1,0) = -3 : Curentblock(3,1,0) = -1 : Curentblock(2,1,0) = -2 : Curentblock(1,1,0) = -1
Curentblock(0,1,1) = 2 : Curentblock(2,1,1) = 1 : Curentblock(1,1,1) = -1
Curentblock(0,1,2) = 2 : Curentblock(2,1,2) = 1 : Curentblock(1,1,2) = 1
Curentblock(0,1,3) = -2 : Curentblock(2,1,3) = -1 : Curentblock(1,1,3) = 1
Curentblock(0,1,4) = -2 : Curentblock(2,1,4) = -1 : Curentblock(1,1,4) = -1
Case #Blk_O
Curentblock(0,0,0) = 5 : Curentblock(1,0,0) = 6 : Curentblock(2,0,0) = 5 : Curentblock(3,0,0) = 6
Curentblock(0,1,0) = -2 : Curentblock(1,1,0) = -2 : Curentblock(2,1,0) = -1 : Curentblock(3,1,0) = -1
Case #Blk_S
Curentblock(0,0,0) = 4 : Curentblock(3,0,0) = 5 : Curentblock(2,0,0) = 5 : Curentblock(1,0,0) = 6
Curentblock(0,0,1) = 1 : Curentblock(2,0,1) = -1 : Curentblock(1,0,1) = -2
Curentblock(0,0,2) = -1 : Curentblock(2,0,2) = 1 : Curentblock(1,0,2) = 2
Curentblock(0,0,3) = 1 : Curentblock(2,0,3) = -1 : Curentblock(1,0,3) = -2
Curentblock(0,0,4) = -1 : Curentblock(2,0,4) = 1 : Curentblock(1,0,4) = 2
Curentblock(0,1,0) = -1 : Curentblock(3,1,0) = -1 : Curentblock(2,1,0) = -2 : Curentblock(1,1,0) = -2
Curentblock(0,1,1) = 1 : Curentblock(2,1,1) = 1 : Curentblock(1,1,1) = 0
Curentblock(0,1,2) = -1 : Curentblock(2,1,2) = -1 : Curentblock(1,1,2) = 0
Curentblock(0,1,3) = 1 : Curentblock(2,1,3) = 1 : Curentblock(1,1,3) = 0
Curentblock(0,1,4) = -1 : Curentblock(2,1,4) = -1 : Curentblock(1,1,4) = 0
Case #Blk_T
Curentblock(0,0,0) = 4 : Curentblock(3,0,0) = 5 : Curentblock(2,0,0) = 6 : Curentblock(1,0,0) = 5
Curentblock(0,0,1) = 1 : Curentblock(2,0,1) = -1 : Curentblock(1,0,1) = 1
Curentblock(0,0,2) = 1 : Curentblock(2,0,2) = -1 : Curentblock(1,0,2) = -1
Curentblock(0,0,3) = -1 : Curentblock(2,0,3) = 1 : Curentblock(1,0,3) = -1
Curentblock(0,0,4) = -1 : Curentblock(2,0,4) = 1 : Curentblock(1,0,4) = 1
Curentblock(0,1,0) = -2 : Curentblock(3,1,0) = -2 : Curentblock(2,1,0) = -2 : Curentblock(1,1,0) = -1
Curentblock(0,1,1) = 1 : Curentblock(2,1,1) = -1 : Curentblock(1,1,1) = -1
Curentblock(0,1,2) = -1 : Curentblock(2,1,2) = 1 : Curentblock(1,1,2) = -1
Curentblock(0,1,3) = -1 : Curentblock(2,1,3) = 1 : Curentblock(1,1,3) = 1
Curentblock(0,1,4) = 1 : Curentblock(2,1,4) = -1 : Curentblock(1,1,4) = 1
Case #Blk_Z
Curentblock(0,0,0) = 4 : Curentblock(3,0,0) = 5 : Curentblock(2,0,0) = 5 : Curentblock(1,0,0) = 6
Curentblock(0,0,1) = 1 : Curentblock(2,0,1) = -1 : Curentblock(1,0,1) = -2
Curentblock(0,0,2) = -1 : Curentblock(2,0,2) = 1 : Curentblock(1,0,2) = 2
Curentblock(0,0,3) = 1 : Curentblock(2,0,3) = -1 : Curentblock(1,0,3) = -2
Curentblock(0,0,4) = -1 : Curentblock(2,0,4) = 1 : Curentblock(1,0,4) = 2
Curentblock(0,1,0) = -2 : Curentblock(3,1,0) = -2 : Curentblock(2,1,0) = -1 : Curentblock(1,1,0) = -1
Curentblock(0,1,1) = -1 : Curentblock(2,1,1) = 0 : Curentblock(1,1,1) = -1
Curentblock(0,1,2) = 1 : Curentblock(2,1,2) = 0 : Curentblock(1,1,2) = 1
Curentblock(0,1,3) = -1 : Curentblock(2,1,3) = 0 : Curentblock(1,1,3) = -1
Curentblock(0,1,4) = 1 : Curentblock(2,1,4) = 0 : Curentblock(1,1,4) = 1 ;}
EndSelect
nextblock = result
Rotation = 0
EndIf
ProcedureReturn result
EndProcedure
Procedure BlockFall()
If CanFall()
For loop = 0 To 3
Curentblock(loop,1,0) = Curentblock(loop,1,0) + 1
Next loop
Else
For loop = 0 To 3
GameZone(Curentblock(loop,0,0),Curentblock(loop,1,0),1) = Curentblock(loop,0,5)
Next loop
CheckFullRow()
MakeDistri()
EndIf
EndProcedure
Procedure CanFall()
Protected result = 1
For loop = 0 To 3
If Curentblock(loop,1,0) = 17
ProcedureReturn #False
EndIf
If Curentblock(loop,1,0) >= 0
If Not GameZone(Curentblock(loop,0,0),Curentblock(loop,1,0)+1,1) = #Blk_Empty
result = 0
EndIf
EndIf
Next loop
ProcedureReturn result
EndProcedure
Procedure CanLeft()
Protected result = 1
For loop = 0 To 3
If Curentblock(loop,0,0) = 1
result = 0 : Break
EndIf
If Curentblock(loop,1,0) > 0
If Not GameZone(Curentblock(loop,0,0)-1,Curentblock(loop,1,0),1) = #Blk_Empty
result = 0
EndIf
EndIf
Next loop
ProcedureReturn result
EndProcedure
Procedure CanRight()
Protected result = 1
For loop = 0 To 3
If Curentblock(loop,0,0) = 10
result = 0 : Break
EndIf
If Curentblock(loop,1,0) > 0
If Not GameZone(Curentblock(loop,0,0)+1,Curentblock(loop,1,0),1) = #Blk_Empty
result = 0
EndIf
EndIf
Next loop
ProcedureReturn result
EndProcedure
Procedure MoveTetra(Direction)
Static DownDelay
Select Direction
Case #MV_Left
If CanLeft()
For loop = 0 To 3
Curentblock(loop,0,0) = Curentblock(loop,0,0) - 1
Next
EndIf
Case #MV_Right
If CanRight()
For loop = 0 To 3
Curentblock(loop,0,0) = Curentblock(loop,0,0) + 1
Next
EndIf
Case #MV_Down
If ElapsedMilliseconds() - DownDelay >= 50
BlockFall()
DownDelay = ElapsedMilliseconds()
EndIf
EndSelect
EndProcedure
Procedure CanRotate()
Protected result = 1, loop2, temp
For loop = 0 To 2
If Curentblock(loop,0,0) + Curentblock(loop,0,Rotation) <= 0
temp = Abs(Curentblock(loop,0,0) + Curentblock(loop,0,Rotation))
For loop2 = 0 To 3
Curentblock(loop2,0,0) + 1+temp
Next loop2
EndIf
If Curentblock(loop,0,0) + Curentblock(loop,0,Rotation) >= 11
temp = Curentblock(loop,0,0) + Curentblock(loop,0,Rotation) - 11
For loop2 = 0 To 3
Curentblock(loop2,0,0) - 1-temp
Next loop2
EndIf
If Curentblock(loop,1,0) + Curentblock(loop,1,rotation) >= 18
ProcedureReturn #False
EndIf
If Curentblock(loop,1,0) + Curentblock(loop,1,rotation) > 0
If Not GameZone(Curentblock(loop,0,0) + Curentblock(loop,0,rotation),Curentblock(loop,1,0) + Curentblock(loop,1,rotation),1) = #Blk_Empty
result = 0
EndIf
EndIf
Next loop
ProcedureReturn result
EndProcedure
Procedure RotateTetra()
If Curentblock(0,0,5) = #Blk_O : ProcedureReturn : EndIf
Rotation + 1
If Rotation = 5 : Rotation = 1 : EndIf
If CanRotate()
Curentblock(0,0,0) + Curentblock(0,0,rotation) : Curentblock(0,1,0) + Curentblock(0,1,rotation)
Curentblock(2,0,0) + Curentblock(2,0,rotation) : Curentblock(2,1,0) + Curentblock(2,1,rotation)
Curentblock(1,0,0) + Curentblock(1,0,rotation) : Curentblock(1,1,0) + Curentblock(1,1,rotation)
Else
Rotation - 1
If Rotation = 0 : rotation = 4 : EndIf
EndIf
EndProcedure
Procedure CheckFullRow()
Protected NewList RowList(), loopX, loopY, full, row, unlock
For loopY = 0 To 17
full = 1
For loopX = 1 To 10
If GameZone(loopX,loopY,1) = #Blk_Empty
full = 0
EndIf
Next loopX
If full
AddElement(RowList())
RowList() = loopY
EndIf
Next loopY
If ListSize(RowList())
FlashFullRow(RowList())
ForEach RowList()
For loopX = 1 To 10
GameZone(loopX,RowList(),1) = #Blk_Empty
Next loopX
Next
LastElement(RowList())
row = RowList()
loop = RowList()
unlock = 17
Repeat
unlock - 1
If unlock = 0
Debug "unlock"
row - 1
EndIf
;Debug row
Repeat
For loopX = 1 To 10
If loop
GameZone(loopX,loop,1) = GameZone(loopX,loop-1,1)
Else
GameZone(loopX,0,1) = #Blk_Empty
EndIf
Next loopX
loop - 1
Until loop = -1
Repeat
full = 10
For loopX = 1 To 10
If GameZone(loopX,row,1) = #Blk_Empty
full -1
EndIf
Next
If full Or RowList() - row >= ListSize(RowList())
row - 1
EndIf
Until full = 0 Or row = 1
loop = row
Until row = 1
If ListSize(RowList()) = 1 : score + 40*(level+1)
ElseIf ListSize(RowList()) = 2 : score + 100*(level+1)
ElseIf ListSize(RowList()) = 3 : score + 300*(level+1)
Else : score + 1200*(level+1) : EndIf
lines + ListSize(RowList())
If Not level = Round(lines/10,#PB_Round_Down)
level = Round(lines/10,#PB_Round_Down)
FallSpeed = 1000 - 50*level
RemoveWindowTimer(Window,0)
AddWindowTimer(Window,0,FallSpeed)
EndIf
EndIf
EndProcedure
Procedure FlashFullRow(List rowlist())
Protected loopx, loopy, flash = 1
loop = 0
Repeat
If loop = 0 Or loop = 2 : flash = 1 : Else : flash = 0 : EndIf
ResetList(rowlist())
NextElement(rowlist())
ClearScreen($200000)
For loopy = 0 To 17
For loopx = 0 To 11
If flash
If loopy = rowlist()
DisplaySprite(#Blk_Empty,loopx*40,loopy*40)
DisplaySprite(GameZone(0,loopy,1),0, loopy * 40)
DisplaySprite(GameZone(11,loopy,1),11 * 40, loopy * 40)
Else
DisplaySprite(GameZone(loopx,loopy,1),loopx * 40, loopy * 40)
EndIf
Else
DisplaySprite(GameZone(loopx,loopy,1),loopx * 40, loopy * 40)
EndIf
Next loopx
If flash And loopy = rowlist()
If Not NextElement(rowlist()) : FirstElement(rowlist()): EndIf
EndIf
Next loopy
StartDrawing(ScreenOutput())
Box(480,100,220,110,$CCFFFF)
Box(480,105,220,45,$003000)
Box(480,155,220,5,$003000)
Box(480,200,220,5,$003000)
Box(500,70,180,60,$CCFFFF)
Box(500,250,180,100,$CCFFFF)
Box(500,360,180,100,$CCFFFF)
Box(530,490,165,165,$CCFFFF)
DrawingMode(#PB_2DDrawing_Outlined)
Box(505,75,170,50,$003000)
Box(505,255,170,90,$003000)
Box(505,365,170,90,$003000)
Box(535,495,155,155,$003000)
DrawingFont(FontID(font))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(515,80,"SCORE",$200000)
DrawText(530,255,"LEVEL",$200000)
DrawText(530,365,"LINES",$200000)
DrawText(515,158,Str(score),$200000)
DrawText(600,300,Str(level),$200000)
DrawText(600,410,Str(lines),$200000)
StopDrawing()
DrawNextBlock()
FlipBuffers()
Delay(200)
loop+ 1
Until loop = 4
EndProcedure