summaryrefslogtreecommitdiff
path: root/gametypes.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'gametypes.bmx')
-rw-r--r--gametypes.bmx51
1 files changed, 28 insertions, 23 deletions
diff --git a/gametypes.bmx b/gametypes.bmx
index 772b9e3..24d1617 100644
--- a/gametypes.bmx
+++ b/gametypes.bmx
@@ -839,36 +839,41 @@ Type TGameMap
special=s
End Method
- Method FlattenColumn(x:Int, y:Int)
- Local diff:Int=0
-
- For Local cy:Int=y-1 To 0 Step -1
- If map[x,cy]
- diff=y-cy
- Exit
+ Method DropColumn(x:Int, y:Int)
+ While y>0
+ map[x,y]=map[x,y-1]
+ y:-1
+ Wend
+ map[x,0]=Null
+ End Method
+
+ Method AnyAbove:Int(x:Int, y:Int)
+ While y>=0
+ If map[x,y]
+ Return True
EndIf
- Next
-
- If diff
- For Local cy:Int=y To diff Step -1
- map[x,cy]=map[x,cy-diff]
- Next
- For Local cy:Int=diff To 0 Step -1
- map[x,cy]=Null
- Next
- EndIf
+ y:-1
+ Wend
- Return diff
+ Return False
End Method
Method Flatten()
For Local x:Int=0 Until Pit.WIDTH
- For Local y:Int=Pit.HEIGHT-1 To 1 Step -1
- If Not map[x,y] And FlattenColumn(x,y)
- Particles.AddDust(Pit.X(x)+16,Pit.Y(y)+32)
- Sound.Click()
+ Local y:Int=Pit.HEIGHT-1
+ Local drop:Int=False
+
+ While y>0 And AnyAbove(x,y)
+ If map[x,y]
+ If drop
+ Particles.AddDust(Pit.X(x)+16,Pit.Y(y)+32)
+ EndIf
+ drop=False
+ y:-1
+ Else
+ DropColumn(x,y)
EndIf
- Next
+ Wend
Next
End Method