diff options
| author | Ian C <ianc@noddybox.co.uk> | 2005-11-26 01:39:40 +0000 | 
|---|---|---|
| committer | Ian C <ianc@noddybox.co.uk> | 2005-11-26 01:39:40 +0000 | 
| commit | 44f5889373f05d53a94a052fedffbd7d6c0f21e0 (patch) | |
| tree | 374a86016083c14d21b7a630cfc7aec92d64b9eb /gametypes.bmx | |
| parent | 8dbb5e4ab32cc2e0d105f51fde19dedb5b2bb2bc (diff) | |
Initial mainly working version
Diffstat (limited to 'gametypes.bmx')
| -rw-r--r-- | gametypes.bmx | 226 | 
1 files changed, 220 insertions, 6 deletions
| diff --git a/gametypes.bmx b/gametypes.bmx index b12972b..8866f5e 100644 --- a/gametypes.bmx +++ b/gametypes.bmx @@ -69,9 +69,9 @@ Type TWire  		t=Rand(0,6)
  	End Method
 -	Function Create:TWire(t:Int)
 +	Function Create:TWire(t:Int[])
  		Local o:TWire=New TWire
 -		o.t=t
 +		o.t=t[Rand(0,t.length-1)]
  		Return o
  	End Function
 @@ -104,6 +104,221 @@ Type TWire  	End Function
  End Type
 +Type TPiece Abstract
 +	Field x:Int
 +	Field y:Int
 +	Field ox:Int
 +	Field oy:Int
 +	Field map:TWire[4,4]
 +	Field rot:Int
 +	Field offx:Int[4]
 +	Field offy:Int[4]
 +	
 +	Function Create:TPiece()
 +		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()
 +		
 +		Return o
 +	End Function
 +	
 +	Method Init() Abstract
 +	
 +	Method BaseInit()
 +		Init()
 +		rot=0
 +		ox=offx[rot]
 +		oy=offy[rot]
 +	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
 +			Next
 +		Next
 +	End Method
 +	
 +	Method RotateLeft()
 +		If rot=0
 +			rot=3
 +		Else
 +			rot:-1
 +		EndIf
 +
 +		ox=offx[rot]
 +		oy=offy[rot]
 +		
 +		Local m:TWire[4,4]
 +		
 +		For Local px:Int=0 Until 4
 +			For Local py:Int=0 Until 4
 +				If map[px,py]
 +					map[px,py].RotateLeft()
 +				EndIf
 +				m[py,3-px]=map[px,py]
 +			Next
 +		Next
 +		
 +		map=m
 +	End Method
 +
 +	Method RotateRight()
 +		rot=(rot+1) Mod 4
 +
 +		ox=offx[rot]
 +		oy=offy[rot]
 +		
 +		Local m:TWire[4,4]
 +		
 +		For Local px:Int=0 Until 4
 +			For Local py:Int=0 Until 4
 +				If map[px,py]
 +					map[px,py].RotateRight()
 +				EndIf
 +				m[3-py,px]=map[px,py]
 +			Next
 +		Next
 +		
 +		map=m
 +	End Method
 +	
 +	Method Collides:Int(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 gx<0 Or gx>=Pit.WIDTH Or gy>=Pit.HEIGHT
 +						Return True
 +					EndIf
 +					
 +					If gy>=0 And gm.map[gx,gy]
 +						Return True
 +					EndIf
 +				EndIf
 +			Next
 +		Next
 +		
 +		Return False
 +	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)
 +					EndIf
 +				EndIf
 +			Next
 +		Next
 +		Sound.Click()
 +		gm.CheckWires()
 +	End Method
 +End Type
 +
 +Type TPiece_S_Right Extends TPiece
 +	Method Init()
 +		map[1,0]=TWire.Create([TWire.CROSS,TWire.BOTTOM_RIGHT])
 +		map[2,0]=TWire.Create([TWire.CROSS,TWire.TOP_LEFT,TWire.BOTTOM_LEFT,TWire.LEFT_RIGHT])
 +		map[0,1]=TWire.Create([TWire.CROSS,TWire.TOP_RIGHT,TWire.BOTTOM_RIGHT,TWire.LEFT_RIGHT])
 +		map[1,1]=TWire.Create([TWire.CROSS,TWire.TOP_LEFT])
 +		offx=[1,2,2,0]
 +		offy=[1,1,2,2]
 +	End Method
 +End Type
 +
 +
 +Type TPiece_S_Left Extends TPiece
 +	Method Init()
 +		map[0,0]=TWire.Create([TWire.CROSS,TWire.TOP_RIGHT,TWire.BOTTOM_RIGHT,TWire.LEFT_RIGHT])
 +		map[1,0]=TWire.Create([TWire.CROSS,TWire.BOTTOM_LEFT])
 +		map[1,1]=TWire.Create([TWire.CROSS,TWire.TOP_RIGHT])
 +		map[2,1]=TWire.Create([TWire.CROSS,TWire.TOP_LEFT,TWire.BOTTOM_LEFT,TWire.LEFT_RIGHT])
 +		offx=[1,2,2,0]
 +		offy=[1,1,2,2]
 +	End Method
 +End Type
 +
 +
 +Type TPiece_L_Right Extends TPiece
 +	Method Init()
 +		map[0,0]=TWire.Create([TWire.CROSS,TWire.BOTTOM_RIGHT])
 +		map[1,0]=TWire.Create([TWire.CROSS,TWire.TOP_LEFT,TWire.BOTTOM_LEFT,TWire.LEFT_RIGHT])
 +		map[0,1]=TWire.Create([TWire.CROSS,TWire.TOP_BOTTOM])
 +		map[0,2]=TWire.Create([TWire.CROSS,TWire.TOP_LEFT,TWire.TOP_RIGHT,TWire.TOP_BOTTOM])
 +		offx=[0,2,3,1]
 +		offy=[1,0,2,3]
 +	End Method
 +End Type
 +
 +
 +Type TPiece_L_Left Extends TPiece
 +	Method Init()
 +		map[0,0]=TWire.Create([TWire.CROSS,TWire.TOP_RIGHT,TWire.BOTTOM_RIGHT,TWire.LEFT_RIGHT])
 +		map[1,0]=TWire.Create([TWire.CROSS,TWire.BOTTOM_LEFT])
 +		map[1,1]=TWire.Create([TWire.CROSS,TWire.TOP_BOTTOM])
 +		map[1,2]=TWire.Create([TWire.CROSS,TWire.TOP_LEFT,TWire.TOP_RIGHT,TWire.TOP_BOTTOM])
 +		offx=[1,2,2,1]
 +		offy=[1,1,2,2]
 +	End Method
 +End Type
 +
 +
 +Type TPiece_Square Extends TPiece
 +	Method Init()
 +		map[0,0]=TWire.Create([TWire.CROSS])
 +		map[1,0]=TWire.Create([TWire.CROSS])
 +		map[0,1]=TWire.Create([TWire.CROSS])
 +		map[1,1]=TWire.Create([TWire.CROSS])
 +		offx=[0,2,2,0]
 +		offy=[1,1,3,3]
 +	End Method
 +End Type
 +
 +
 +Type TPiece_Bar Extends TPiece
 +	Method Init()
 +		map[1,0]=TWire.Create([TWire.CROSS,TWire.BOTTOM_LEFT,TWire.BOTTOM_RIGHT,TWire.TOP_BOTTOM])
 +		map[1,1]=TWire.Create([TWire.CROSS,TWire.TOP_BOTTOM])
 +		map[1,2]=TWire.Create([TWire.CROSS,TWire.TOP_BOTTOM])
 +		map[1,3]=TWire.Create([TWire.CROSS,TWire.TOP_LEFT,TWire.TOP_RIGHT,TWire.TOP_BOTTOM])
 +		offx=[1,1,2,1]
 +		offy=[1,1,1,2]
 +	End Method
 +End Type
 +
 +
  Type TFallingBlock
  	Field w:TWire
  	Field x:Int
 @@ -132,6 +347,7 @@ Type TFallingBlock  	End Method
  End Type
 +
  Type TWireListEnt
  	Field w:TWire
  	Field x:Int
 @@ -146,6 +362,7 @@ Type TWireListEnt  	End Function
  End Type
 +
  Type TWireList
  	Field list:TList
  	Field col:Int
 @@ -271,7 +488,7 @@ Type TGameMap  		x:+TWire.DirX(dir)
  		y:+TWire.DirY(dir)
 -		If x=ox And y=oy
 +		If x=ox And y=oy And dir=TWire.DIR_LEFT
  			Return True
  		EndIf
 @@ -464,9 +681,6 @@ Type TGameMap  			EndIf
  		EndIf
 -		SetColor(trode_col,trode_col,0)
 -		DrawImage(GameGFX.cursor,Pit.X(cx),Pit.Y(cy))
 -		
  		trode_col:+trode_coli
  		If (trode_col=255 And trode_coli>0) Or (trode_col=200 And trode_coli<0)
 | 
