summaryrefslogtreecommitdiff
path: root/gametypes.bmx
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-11-29 20:35:03 +0000
committerIan C <ianc@noddybox.co.uk>2005-11-29 20:35:03 +0000
commit991c2de75c4d8d78e135d38eae2dfbd09ac0573a (patch)
treeeb35adc13d226828db62a627788b66693ff516d3 /gametypes.bmx
parent44f5889373f05d53a94a052fedffbd7d6c0f21e0 (diff)
Implementing new special block code
Diffstat (limited to 'gametypes.bmx')
-rw-r--r--gametypes.bmx440
1 files changed, 241 insertions, 199 deletions
diff --git a/gametypes.bmx b/gametypes.bmx
index 8866f5e..004e69e 100644
--- a/gametypes.bmx
+++ b/gametypes.bmx
@@ -11,14 +11,14 @@ Import "sounds.bmx"
Type Pit
Const WIDTH=10
- Const HEIGHT=14
+ Const HEIGHT=13
Function X:Int(p:Int)
Return 230+p*32
End Function
Function Y:Int(p:Int)
- Return 96+p*32
+ Return 120+p*32
End Function
End Type
@@ -30,6 +30,8 @@ Type TWire
Const TOP_RIGHT:Int=4
Const BOTTOM_LEFT:Int=5
Const BOTTOM_RIGHT:Int=6
+ Const SPECIAL_BOMB:Int=7
+ Const SPECIAL_TWISTER:Int=8
Const DIR_NONE:Int=0
Const DIR_UP:Int=1
@@ -50,19 +52,19 @@ Type TWire
Field t:Int
Function Init()
- rotright=[0,2,1,4,6,3,5]
- rotleft=[0,2,1,5,3,6,4]
+ rotright=[0,2,1,4,6,3,5,7,8]
+ rotleft=[0,2,1,5,3,6,4,7,8]
- img=[GameGFX.cross,GameGFX.left_right,GameGFX.top_bottom,GameGFX.top_left,GameGFX.top_right,GameGFX.bottom_left,GameGFX.bottom_right]
+ img=[GameGFX.cross,GameGFX.left_right,GameGFX.top_bottom,GameGFX.top_left,GameGFX.top_right,GameGFX.bottom_left,GameGFX.bottom_right,GameGFX.special_bomb,GameGFX.special_twister]
- ' CROSS LEFT_RIGHT TOP_BOTTOM TOP_LEFT TOP_RIGHT BOTTOM_LEFT BOTTOM_RIGHT
- dir=[[DIR_UP,DIR_RIGHT,DIR_DOWN,DIR_LEFT], [DIR_NONE,DIR_RIGHT,DIR_NONE,DIR_LEFT], [DIR_UP,DIR_NONE,DIR_DOWN,DIR_NONE], [DIR_NONE,DIR_UP,DIR_LEFT,DIR_NONE], [DIR_NONE,DIR_NONE,DIR_RIGHT,DIR_UP], [DIR_LEFT,DIR_DOWN,DIR_NONE,DIR_NONE], [DIR_RIGHT,DIR_NONE,DIR_NONE,DIR_DOWN]]
+ ' CROSS LEFT_RIGHT TOP_BOTTOM TOP_LEFT TOP_RIGHT BOTTOM_LEFT BOTTOM_RIGHT SPECIAL_BOMB SPECIAL_TWISTER
+ dir=[[DIR_UP,DIR_RIGHT,DIR_DOWN,DIR_LEFT], [DIR_NONE,DIR_RIGHT,DIR_NONE,DIR_LEFT], [DIR_UP,DIR_NONE,DIR_DOWN,DIR_NONE], [DIR_NONE,DIR_UP,DIR_LEFT,DIR_NONE], [DIR_NONE,DIR_NONE,DIR_RIGHT,DIR_UP], [DIR_LEFT,DIR_DOWN,DIR_NONE,DIR_NONE], [DIR_RIGHT,DIR_NONE,DIR_NONE,DIR_DOWN], [DIR_NONE,DIR_NONE,DIR_NONE,DIR_NONE], [DIR_NONE,DIR_NONE,DIR_NONE,DIR_NONE]]
dx=[0,0,1,0,-1]
dy=[0,-1,0,1,0]
dirname=["NONE","UP","RIGHT","DOWN","LEFT"]
- typename=["CROSS","LEFT_RIGHT","TOP_BOTTOM","TOP_LEFT","TOP_RIGHT","BOTTOM_LEFT","BOTTOM_RIGHT"]
+ typename=["CROSS","LEFT_RIGHT","TOP_BOTTOM","TOP_LEFT","TOP_RIGHT","BOTTOM_LEFT","BOTTOM_RIGHT","SPECIAL BOMB","SPECIAL TWISTER"]
End Function
Method New()
@@ -113,55 +115,106 @@ Type TPiece Abstract
Field rot:Int
Field offx:Int[4]
Field offy:Int[4]
+ Field special:Int
+ Field special_pulse:Int
+ Field col:Int
+ Field coli:Int
+ Field frame:Int
+ Field framed:Int
- Function Create:TPiece()
+ Function Create:TPiece(special:Int)
Local o:TPiece
- Select Rand(0,5)
- Case 0
- o=TPiece(New TPiece_S_Left)
- Case 1
- o=TPiece(New TPiece_S_Right)
- Case 2
- o=TPiece(New TPiece_L_Left)
- Case 3
- o=TPiece(New TPiece_L_Right)
- Case 4
- o=TPiece(New TPiece_Square)
- Case 5
- o=TPiece(New TPiece_Bar)
- End Select
-
- o.BaseInit()
+ If special
+ Select Rand(0,5)
+ Case 0
+ o=TPiece(New TPiece_SpecialBomb)
+ Case 1
+ o=TPiece(New TPiece_SpecialTwister)
+ End Select
+ Else
+ Select Rand(0,5)
+ Case 0
+ o=TPiece(New TPiece_S_Left)
+ Case 1
+ o=TPiece(New TPiece_S_Right)
+ Case 2
+ o=TPiece(New TPiece_L_Left)
+ Case 3
+ o=TPiece(New TPiece_L_Right)
+ Case 4
+ o=TPiece(New TPiece_Square)
+ Case 5
+ o=TPiece(New TPiece_Bar)
+ End Select
+ EndIf
+
+ o.BaseInit(special)
Return o
End Function
Method Init() Abstract
- Method BaseInit()
+ Method BaseInit(special:Int)
+ special_pulse=False
Init()
rot=0
ox=offx[rot]
oy=offy[rot]
+ self.special=special
+ col=255
+ coli=-1
+ frame=0
+ framed=0
End Method
Method Draw()
- For Local px:Int=0 Until 4
- For Local py:Int=0 Until 4
- If map[px,py]
- Local gx:Int=Pit.X(x-ox+px)
- Local gy:Int=Pit.Y(y-oy+py)
- SetColor(255,255,255)
- DrawImage(GameGFX.tile,gx,gy)
- SetColor(128,128,128)
- DrawImage(map[px,py].Image(),gx,gy)
- EndIf
+ If special
+ col:+coli
+ If col=255 Or col=128
+ coli=-coli
+ EndIf
+
+ framed:+1
+ If framed=5
+ framed=0
+ frame=(frame+1) Mod 4
+ EndIf
+
+ For Local px:Int=0 Until 4
+ For Local py:Int=0 Until 4
+ If map[px,py]
+ Local gx:Int=Pit.X(x-ox+px)
+ Local gy:Int=Pit.Y(y-oy+py)
+ SetColor(255,255,255)
+ DrawImage(GameGFX.tile,gx,gy)
+ If special_pulse
+ SetColor(col,col/2,255-col)
+ EndIf
+ DrawImage(map[px,py].Image(),gx,gy,frame)
+ EndIf
+ Next
Next
- Next
+ Else
+ For Local px:Int=0 Until 4
+ For Local py:Int=0 Until 4
+ If map[px,py]
+ Local gx:Int=Pit.X(x-ox+px)
+ Local gy:Int=Pit.Y(y-oy+py)
+ SetColor(255,255,255)
+ DrawImage(GameGFX.tile,gx,gy)
+ SetColor(128,128,128)
+ DrawImage(map[px,py].Image(),gx,gy)
+ EndIf
+ Next
+ Next
+ EndIf
End Method
Method RotateLeft()
+ If special Then Return
+
If rot=0
rot=3
Else
@@ -186,6 +239,8 @@ Type TPiece Abstract
End Method
Method RotateRight()
+ If special Then Return
+
rot=(rot+1) Mod 4
ox=offx[rot]
@@ -227,26 +282,44 @@ Type TPiece Abstract
End Method
Method AddToMap(gm:TGameMap)
- For Local px:Int=0 Until 4
- For Local py:Int=0 Until 4
- If map[px,py]
- Local gx:Int=x-ox+px
- Local gy:Int=y-oy+py
-
- If gy<0
- gm.overflow=True
- Else
- gm.map[gx,gy]=map[px,py]
- Particles.AddDust(Pit.X(gx)+16,Pit.Y(gy)+32)
+ If special
+ gm.SetSpecial(TSpecial(Self))
+ Else
+ For Local px:Int=0 Until 4
+ For Local py:Int=0 Until 4
+ If map[px,py]
+ Local gx:Int=x-ox+px
+ Local gy:Int=y-oy+py
+
+ If gy<0
+ gm.overflow=True
+ Else
+ gm.map[gx,gy]=map[px,py]
+
+ If gy=Pit.HEIGHT-1 Or gm.map[gx,gy+1]
+ Particles.AddDust(Pit.X(gx)+16,Pit.Y(gy)+32)
+ EndIf
+ EndIf
EndIf
- EndIf
+ Next
Next
- Next
- Sound.Click()
- gm.CheckWires()
+
+ Sound.Click()
+
+ If Not gm.overflow
+ If Not gm.CheckWires()
+ gm.Flatten()
+ gm.CheckWires()
+ EndIf
+ EndIf
+ EndIf
End Method
End Type
+Type TSpecial Extends TPiece Abstract
+ Method DoSpecial:Int(gm:TGameMap) Abstract
+End Type
+
Type TPiece_S_Right Extends TPiece
Method Init()
map[1,0]=TWire.Create([TWire.CROSS,TWire.BOTTOM_RIGHT])
@@ -318,32 +391,49 @@ Type TPiece_Bar Extends TPiece
End Method
End Type
-
-Type TFallingBlock
- Field w:TWire
- Field x:Int
- Field y:Double
- Field yi:Double
+Type TPiece_SpecialBomb Extends TSpecial
+ Method Init()
+ map[0,0]=TWire.Create([TWire.SPECIAL_BOMB])
+ offx=[0,0,0,0]
+ offy=[0,0,0,0]
+ End Method
- Function Create:TFallingBlock(x:Int, y:Double)
- Local o:TFallingBlock=New TFallingBlock
- o.w=New TWire
- o.x=x
- o.y=y
- o.yi=0
- Return o
- End Function
+ Method DoSpecial:Int(gm:TGameMap)
+ Local l:TWireList=New TWireList
- Method Update()
- y:+yi
- yi=Max(4.0,yi+0.1)
+ If y<Pit.HEIGHT-1
+ Local t:Int=map[x,y+1].t
+
+ For Local px:Int=0 Until Pit.WIDTH
+ For Local py:Int=0 Until Pit.HEIGHT
+ If gm.map[px,py] And map[px,py].t=t
+ l.Add(px,py,gm.map[px,py])
+ EndIf
+ Next
+ Next
+ EndIf
+
+ If l.Count()=0
+ TextParticles.Big("WHAT A WASTE!",255,0,0)
+ Else
+ TextParticles.Big("SPECIAL GOT " + (l.Count()-1) + " BLOCKS!",255,255,0)
+ EndIf
+
+ gm.path.AddLast(l)
+
+ Return False
+ End Method
+End Type
+
+Type TPiece_SpecialTwister Extends TSpecial
+ Method Init()
+ special_pulse=True
+ map[0,0]=TWire.Create([TWire.SPECIAL_TWISTER])
+ offx=[0,0,0,0]
+ offy=[0,0,0,0]
End Method
- Method Draw()
- SetColor(255,255,255)
- DrawImage(GameGFX.tile,Pit.X(x),y)
- SetColor(128,128,128)
- DrawImage(w.Image(),Pit.X(x),y)
+ Method DoSpecial:Int(gm:TGameMap)
End Method
End Type
@@ -377,7 +467,7 @@ Type TWireList
End Method
Method Draw:Int()
- col=Max(255,col+5)
+ col=Min(255,col+5)
SetColor(col,col,col)
For Local e:TWireListEnt=EachIn list
DrawImage(e.w.Image(),Pit.X(e.x),Pit.Y(e.y))
@@ -392,52 +482,33 @@ Type TWireList
Return False
EndIf
End Method
+
+ Method Count:Int()
+ Return list.Count()
+ End Method
End Type
+
Type TGameMap
Field map:TWire[Pit.WIDTH,Pit.HEIGHT]
Field trode_col:Int
Field trode_coli:Int
Field overflow:Int
- Field top:Int[Pit.WIDTH]
- Field drop:TList
Field cx:Int
Field cy:Int
Field path:TList
+ Field special:TSpecial
Method New()
trode_col=0
trode_coli=1
overflow=False
- drop=CreateList()
path=CreateList()
- CalcTop()
- cx=0
- cy=Pit.HEIGHT-2
- End Method
-
- Method CalcTop()
- For Local x:Int=0 Until Pit.WIDTH
- top[x]=-1
- For Local y:Int=Pit.Height-1 To 0 Step -1
- If Not map[x,y]
- top[x]=y
- Exit
- EndIf
- Next
- Next
- End Method
-
- Method AddRow(y:Int=-32)
- If BlockInteract() Then Return
-
- For Local x:Int=0 Until Pit.WIDTH
- drop.AddLast(TFallingBlock.Create(x,y))
- Next
+ special=Null
End Method
Method BlockInteract:Int()
- Return overflow Or path.Count()
+ Return overflow Or path.Count() Or special
End Method
Method FindPath:Int(l:TWireList, x:Int, y:Int, dir:Int)
@@ -488,14 +559,17 @@ Type TGameMap
x:+TWire.DirX(dir)
y:+TWire.DirY(dir)
- If x=ox And y=oy And dir=TWire.DIR_LEFT
+ If x=ox And y=oy And dir=TWire.DIR_RIGHT
Return True
EndIf
Return FindLoop(l,ox,oy,x,y,dir)
End Method
- Method CheckWires()
+ Method CheckWires:Int()
+ Local loop:Int=False
+ Local wire:Int=False
+
For Local y:Int=0 Until Pit.HEIGHT
Local l:TWireList=New TWireList
@@ -507,6 +581,7 @@ Type TGameMap
If FindPath(l,Pit.WIDTH-1,y,TWire.DIR_LEFT)
path.AddLast(l)
+ wire=True
EndIf
Next
@@ -515,6 +590,7 @@ Type TGameMap
If FindPath(l,x,Pit.HEIGHT-1,TWire.DIR_UP)
path.AddLast(l)
+ wire=True
EndIf
Next
@@ -524,52 +600,61 @@ Type TGameMap
Local l:TWireList=New TWireList
Select map[x,y].t
Case TWire.CROSS, TWire.LEFT_RIGHT, TWire.TOP_LEFT, TWire.BOTTOM_LEFT
- If FindLoop(l,x,y,x,y,TWire.DIR_LEFT)
+ If FindLoop(l,x,y,x,y,TWire.DIR_RIGHT)
path.AddLast(l)
+ loop=True
EndIf
End Select
EndIf
Next
Next
+
+ If loop And wire
+ TextParticles.Big("LOOP AND WIRE",255,0,255)
+ ElseIf loop
+ TextParticles.Big("LOOP",255,0,255)
+ ElseIf wire
+ TextParticles.Big("WIRE",255,0,255)
+ EndIf
+
+ Return loop Or wire
End Method
- Method CursorLeft()
- If BlockInteract() Then Return
- cx=Max(0,cx-1)
- End Method
-
- Method CursorRight()
- If BlockInteract() Then Return
- cx=Min(Pit.WIDTH-2,cx+1)
- End Method
-
- Method CursorUp()
- If BlockInteract() Then Return
- cy=Max(0,cy-1)
+ Method SetSpecial(s:TSpecial)
+ special=s
End Method
- Method CursorDown()
- If BlockInteract() Then Return
- cy=Min(Pit.HEIGHT-2,cy+1)
+ 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
+ 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
+
+ Return diff
End Method
- Method Rotate()
- If BlockInteract() Then Return
- Local done:Int=False
- For Local x:Int=0 To 1
- For Local y:Int=0 To 1
- If map[cx+x,cy+y]
- map[cx+x,cy+y].RotateRight()
- done=True
+ 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()
EndIf
Next
Next
-
- If done
- Sound.Click()
- EndIf
-
- CheckWires()
End Method
Method Draw:Int()
@@ -612,73 +697,30 @@ Type TGameMap
Next
Next
- If BlockInteract()
- For Local b:TFallingBlock=EachIn drop
- b.Draw()
- Next
-
- Local l:TEasyLink=TEasyLink.Create(path)
- Local check:Int=False
-
- While l.Value()
- Local b:TWireList=TWireList(l.Value())
-
- If b.Draw()
- l.MoveNext()
- Else
- If Not overflow
- score:+b.list.Count()
- For Local e:TWireListEnt=EachIn b.list
- For Local y:Int=e.y To 1 Step -1
- map[e.x,y]=map[e.x,y-1]
- Next
- map[e.x,0]=Null
- Particles.AddDust(Pit.X(e.x)+16,Pit.Y(e.y)+32)
- check=True
- Next
- EndIf
- l.Remove()
- EndIf
- Wend
-
- If check
- Sound.Path()
- CalcTop()
- CheckWires()
- EndIf
- Else
- Local hit:Int=False
-
- Local l:TEasyLink=TEasyLink.Create(drop)
+ Local l:TEasyLink=TEasyLink.Create(path)
+ Local check:Int=False
+
+ While l.Value()
+ Local b:TWireList=TWireList(l.Value())
- While l.Value()
- Local b:TFallingBlock=TFallingBlock(l.Value())
- Local t:Int=Pit.Y(top[b.x])'-ImageHeight(GameGFX.tile)
-
- b.Update()
-
- If b.y>t
- If top[b.x]=-1
- overflow=True
- b.y=t
- l.MoveNext()
- Else
- hit=True
- map[b.x,top[b.x]]=b.w
- Particles.AddDust(Pit.X(b.x)+16,Pit.Y(top[b.x])+32)
- l.Remove()
- EndIf
- Else
- b.Draw()
- l.MoveNext()
+ If b.Draw()
+ l.MoveNext()
+ Else
+ If Not overflow
+ score:+b.list.Count()
+ For Local e:TWireListEnt=EachIn b.list
+ map[e.x,e.y]=Null
+ Next
EndIf
- Wend
-
- If hit And Not overflow
- Sound.Click()
- CheckWires()
- CalcTop()
+ l.Remove()
+ check=True
EndIf
+ Wend
+
+ If check
+ Sound.Path()
+ Flatten()
+ CheckWires()
EndIf
trode_col:+trode_coli