From 991c2de75c4d8d78e135d38eae2dfbd09ac0573a Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 29 Nov 2005 20:35:03 +0000 Subject: Implementing new special block code --- gametypes.bmx | 440 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 241 insertions(+), 199 deletions(-) (limited to 'gametypes.bmx') 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 yt - 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 -- cgit v1.2.3