diff options
-rw-r--r-- | .cvsignore | 4 | ||||
-rw-r--r-- | GFX/button.pspimage | bin | 0 -> 17908 bytes | |||
-rw-r--r-- | GFX/copper.png | bin | 0 -> 465 bytes | |||
-rw-r--r-- | GFX/copperslice.png | bin | 0 -> 281 bytes | |||
-rw-r--r-- | GFX/cursor.png | bin | 0 -> 1377 bytes | |||
-rw-r--r-- | GFX/dust.png | bin | 0 -> 154 bytes | |||
-rw-r--r-- | GFX/font.bmf | bin | 0 -> 21036 bytes | |||
-rw-r--r-- | GFX/keys_button.png | bin | 0 -> 6969 bytes | |||
-rw-r--r-- | GFX/large.bmf | bin | 0 -> 136704 bytes | |||
-rw-r--r-- | GFX/left_button.png | bin | 0 -> 1082 bytes | |||
-rw-r--r-- | GFX/play_button.png | bin | 0 -> 6484 bytes | |||
-rw-r--r-- | GFX/pointer.png | bin | 0 -> 206 bytes | |||
-rw-r--r-- | GFX/quit_button.png | bin | 0 -> 6662 bytes | |||
-rw-r--r-- | GFX/right_button.png | bin | 0 -> 1049 bytes | |||
-rw-r--r-- | GFX/scores_button.png | bin | 0 -> 7943 bytes | |||
-rw-r--r-- | GFX/small.bmf | bin | 0 -> 9888 bytes | |||
-rw-r--r-- | GFX/title.png | bin | 0 -> 12018 bytes | |||
-rw-r--r-- | SFX/click.wav | bin | 0 -> 3530 bytes | |||
-rw-r--r-- | SFX/path.wav | bin | 0 -> 33342 bytes | |||
-rw-r--r-- | SFX/pop.wav | bin | 0 -> 9112 bytes | |||
-rw-r--r-- | TILES/bottom_left.png | bin | 0 -> 207 bytes | |||
-rw-r--r-- | TILES/bottom_right.png | bin | 0 -> 214 bytes | |||
-rw-r--r-- | TILES/cross.png | bin | 0 -> 220 bytes | |||
-rw-r--r-- | TILES/left_right.png | bin | 0 -> 187 bytes | |||
-rw-r--r-- | TILES/pit_bottom.png | bin | 0 -> 195 bytes | |||
-rw-r--r-- | TILES/pit_bottomleft.png | bin | 0 -> 216 bytes | |||
-rw-r--r-- | TILES/pit_bottomright.png | bin | 0 -> 214 bytes | |||
-rw-r--r-- | TILES/pit_side.png | bin | 0 -> 203 bytes | |||
-rw-r--r-- | TILES/pit_top.png | bin | 0 -> 197 bytes | |||
-rw-r--r-- | TILES/tile.png | bin | 0 -> 1633 bytes | |||
-rw-r--r-- | TILES/tiles.bms | bin | 0 -> 70074 bytes | |||
-rw-r--r-- | TILES/top_bottom.png | bin | 0 -> 188 bytes | |||
-rw-r--r-- | TILES/top_left.png | bin | 0 -> 220 bytes | |||
-rw-r--r-- | TILES/top_right.png | bin | 0 -> 226 bytes | |||
-rw-r--r-- | TILES/trode_bottom.png | bin | 0 -> 254 bytes | |||
-rw-r--r-- | TILES/trode_left.png | bin | 0 -> 259 bytes | |||
-rw-r--r-- | TILES/trode_right.png | bin | 0 -> 261 bytes | |||
-rw-r--r-- | game.bmx | 20 | ||||
-rw-r--r-- | gametypes.bmx | 478 | ||||
-rw-r--r-- | hardwire.bmx | 255 | ||||
-rw-r--r-- | particle.bmx | 100 | ||||
-rw-r--r-- | sounds.bmx | 35 | ||||
-rw-r--r-- | types.bmx | 295 |
43 files changed, 1187 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..bf70089 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,4 @@ +*.exe
+.bmx
+hardwire.config
+hardwire.hiscore
diff --git a/GFX/button.pspimage b/GFX/button.pspimage Binary files differnew file mode 100644 index 0000000..9039782 --- /dev/null +++ b/GFX/button.pspimage diff --git a/GFX/copper.png b/GFX/copper.png Binary files differnew file mode 100644 index 0000000..002b101 --- /dev/null +++ b/GFX/copper.png diff --git a/GFX/copperslice.png b/GFX/copperslice.png Binary files differnew file mode 100644 index 0000000..e786b9b --- /dev/null +++ b/GFX/copperslice.png diff --git a/GFX/cursor.png b/GFX/cursor.png Binary files differnew file mode 100644 index 0000000..c420374 --- /dev/null +++ b/GFX/cursor.png diff --git a/GFX/dust.png b/GFX/dust.png Binary files differnew file mode 100644 index 0000000..65476f3 --- /dev/null +++ b/GFX/dust.png diff --git a/GFX/font.bmf b/GFX/font.bmf Binary files differnew file mode 100644 index 0000000..364f158 --- /dev/null +++ b/GFX/font.bmf diff --git a/GFX/keys_button.png b/GFX/keys_button.png Binary files differnew file mode 100644 index 0000000..f712071 --- /dev/null +++ b/GFX/keys_button.png diff --git a/GFX/large.bmf b/GFX/large.bmf Binary files differnew file mode 100644 index 0000000..28d4532 --- /dev/null +++ b/GFX/large.bmf diff --git a/GFX/left_button.png b/GFX/left_button.png Binary files differnew file mode 100644 index 0000000..2d470f1 --- /dev/null +++ b/GFX/left_button.png diff --git a/GFX/play_button.png b/GFX/play_button.png Binary files differnew file mode 100644 index 0000000..afab315 --- /dev/null +++ b/GFX/play_button.png diff --git a/GFX/pointer.png b/GFX/pointer.png Binary files differnew file mode 100644 index 0000000..ed222e5 --- /dev/null +++ b/GFX/pointer.png diff --git a/GFX/quit_button.png b/GFX/quit_button.png Binary files differnew file mode 100644 index 0000000..34b54c2 --- /dev/null +++ b/GFX/quit_button.png diff --git a/GFX/right_button.png b/GFX/right_button.png Binary files differnew file mode 100644 index 0000000..4f95c40 --- /dev/null +++ b/GFX/right_button.png diff --git a/GFX/scores_button.png b/GFX/scores_button.png Binary files differnew file mode 100644 index 0000000..52a8f55 --- /dev/null +++ b/GFX/scores_button.png diff --git a/GFX/small.bmf b/GFX/small.bmf Binary files differnew file mode 100644 index 0000000..16d8db4 --- /dev/null +++ b/GFX/small.bmf diff --git a/GFX/title.png b/GFX/title.png Binary files differnew file mode 100644 index 0000000..f83788a --- /dev/null +++ b/GFX/title.png diff --git a/SFX/click.wav b/SFX/click.wav Binary files differnew file mode 100644 index 0000000..74a37bb --- /dev/null +++ b/SFX/click.wav diff --git a/SFX/path.wav b/SFX/path.wav Binary files differnew file mode 100644 index 0000000..ed14b28 --- /dev/null +++ b/SFX/path.wav diff --git a/SFX/pop.wav b/SFX/pop.wav Binary files differnew file mode 100644 index 0000000..e9a4523 --- /dev/null +++ b/SFX/pop.wav diff --git a/TILES/bottom_left.png b/TILES/bottom_left.png Binary files differnew file mode 100644 index 0000000..943b8e3 --- /dev/null +++ b/TILES/bottom_left.png diff --git a/TILES/bottom_right.png b/TILES/bottom_right.png Binary files differnew file mode 100644 index 0000000..038e2f4 --- /dev/null +++ b/TILES/bottom_right.png diff --git a/TILES/cross.png b/TILES/cross.png Binary files differnew file mode 100644 index 0000000..dda76a6 --- /dev/null +++ b/TILES/cross.png diff --git a/TILES/left_right.png b/TILES/left_right.png Binary files differnew file mode 100644 index 0000000..05f3c88 --- /dev/null +++ b/TILES/left_right.png diff --git a/TILES/pit_bottom.png b/TILES/pit_bottom.png Binary files differnew file mode 100644 index 0000000..9ea0eda --- /dev/null +++ b/TILES/pit_bottom.png diff --git a/TILES/pit_bottomleft.png b/TILES/pit_bottomleft.png Binary files differnew file mode 100644 index 0000000..925e523 --- /dev/null +++ b/TILES/pit_bottomleft.png diff --git a/TILES/pit_bottomright.png b/TILES/pit_bottomright.png Binary files differnew file mode 100644 index 0000000..a6aa435 --- /dev/null +++ b/TILES/pit_bottomright.png diff --git a/TILES/pit_side.png b/TILES/pit_side.png Binary files differnew file mode 100644 index 0000000..12153f4 --- /dev/null +++ b/TILES/pit_side.png diff --git a/TILES/pit_top.png b/TILES/pit_top.png Binary files differnew file mode 100644 index 0000000..5fb78c2 --- /dev/null +++ b/TILES/pit_top.png diff --git a/TILES/tile.png b/TILES/tile.png Binary files differnew file mode 100644 index 0000000..f3f59fa --- /dev/null +++ b/TILES/tile.png diff --git a/TILES/tiles.bms b/TILES/tiles.bms Binary files differnew file mode 100644 index 0000000..d367fb0 --- /dev/null +++ b/TILES/tiles.bms diff --git a/TILES/top_bottom.png b/TILES/top_bottom.png Binary files differnew file mode 100644 index 0000000..12a90fd --- /dev/null +++ b/TILES/top_bottom.png diff --git a/TILES/top_left.png b/TILES/top_left.png Binary files differnew file mode 100644 index 0000000..92a4c7d --- /dev/null +++ b/TILES/top_left.png diff --git a/TILES/top_right.png b/TILES/top_right.png Binary files differnew file mode 100644 index 0000000..2897871 --- /dev/null +++ b/TILES/top_right.png diff --git a/TILES/trode_bottom.png b/TILES/trode_bottom.png Binary files differnew file mode 100644 index 0000000..bb0666c --- /dev/null +++ b/TILES/trode_bottom.png diff --git a/TILES/trode_left.png b/TILES/trode_left.png Binary files differnew file mode 100644 index 0000000..debac67 --- /dev/null +++ b/TILES/trode_left.png diff --git a/TILES/trode_right.png b/TILES/trode_right.png Binary files differnew file mode 100644 index 0000000..67f1160 --- /dev/null +++ b/TILES/trode_right.png diff --git a/game.bmx b/game.bmx new file mode 100644 index 0000000..0df53c5 --- /dev/null +++ b/game.bmx @@ -0,0 +1,20 @@ +' Hardwire
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import "types.bmx"
+Import "gametypes.bmx"
+
+Type TGame
+ Field score:Int
+ Field gm:TGameMap
+
+ Method New()
+ score=0
+ gm=New TGameMap
+ End Method
+End Type
+
diff --git a/gametypes.bmx b/gametypes.bmx new file mode 100644 index 0000000..b12972b --- /dev/null +++ b/gametypes.bmx @@ -0,0 +1,478 @@ +' Hardwire
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import "types.bmx"
+Import "particle.bmx"
+Import "sounds.bmx"
+
+Type Pit
+ Const WIDTH=10
+ Const HEIGHT=14
+
+ Function X:Int(p:Int)
+ Return 230+p*32
+ End Function
+
+ Function Y:Int(p:Int)
+ Return 96+p*32
+ End Function
+End Type
+
+Type TWire
+ Const CROSS:Int=0
+ Const LEFT_RIGHT:Int=1
+ Const TOP_BOTTOM:Int=2
+ Const TOP_LEFT:Int=3
+ Const TOP_RIGHT:Int=4
+ Const BOTTOM_LEFT:Int=5
+ Const BOTTOM_RIGHT:Int=6
+
+ Const DIR_NONE:Int=0
+ Const DIR_UP:Int=1
+ Const DIR_RIGHT:Int=2
+ Const DIR_DOWN:Int=3
+ Const DIR_LEFT:Int=4
+
+ Global rotright:Int[]
+ Global rotleft:Int[]
+ Global img:TImage[]
+ Global dir:Int[][]
+ Global dx:Int[]
+ Global dy:Int[]
+
+ Global dirname:String[]
+ Global typename:String[]
+
+ Field t:Int
+
+ Function Init()
+ rotright=[0,2,1,4,6,3,5]
+ rotleft=[0,2,1,5,3,6,4]
+
+ img=[GameGFX.cross,GameGFX.left_right,GameGFX.top_bottom,GameGFX.top_left,GameGFX.top_right,GameGFX.bottom_left,GameGFX.bottom_right]
+
+ ' 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]]
+
+ 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"]
+ End Function
+
+ Method New()
+ t=Rand(0,6)
+ End Method
+
+ Function Create:TWire(t:Int)
+ Local o:TWire=New TWire
+ o.t=t
+ Return o
+ End Function
+
+ Method Image:TImage()
+ Return img[t]
+ End Method
+
+ Method RotateLeft()
+ t=rotleft[t]
+ End Method
+
+ Method RotateRight()
+ t=rotright[t]
+ End Method
+
+ Method Traverse:Int(d:Int)
+ If d=DIR_NONE
+ Return DIR_NONE
+ EndIf
+
+ Return dir[t][d-1]
+ End Method
+
+ Function DirX:Int(d:Int)
+ Return dx[d]
+ End Function
+
+ Function DirY:Int(d:Int)
+ Return dy[d]
+ End Function
+End Type
+
+Type TFallingBlock
+ Field w:TWire
+ Field x:Int
+ Field y:Double
+ Field yi:Double
+
+ 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 Update()
+ y:+yi
+ yi=Max(4.0,yi+0.1)
+ 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)
+ End Method
+End Type
+
+Type TWireListEnt
+ Field w:TWire
+ Field x:Int
+ Field y:Int
+
+ Function Create:TWireListEnt(x:Int, y:Int, w:TWire)
+ Local o:TWireListEnt=New TWireListEnt
+ o.x=x
+ o.y=y
+ o.w=w
+ Return o
+ End Function
+End Type
+
+Type TWireList
+ Field list:TList
+ Field col:Int
+
+ Method New()
+ list=CreateList()
+ col=128
+ End Method
+
+ Method Add(x:Int, y:Int, w:TWire)
+ list.AddLast(TWireListEnt.Create(x,y,w))
+ End Method
+
+ Method Draw:Int()
+ col=Max(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))
+ Next
+
+ If col<255
+ Return True
+ Else
+ For Local e:TWireListEnt=EachIn list
+ Particles.AddImage(e.w.Image(),Pit.X(e.x),Pit.Y(e.y))
+ Next
+ Return False
+ EndIf
+ 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
+
+ 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
+ End Method
+
+ Method BlockInteract:Int()
+ Return overflow Or path.Count()
+ End Method
+
+ Method FindPath:Int(l:TWireList, x:Int, y:Int, dir:Int)
+ If y<0
+ Return False
+ EndIf
+
+ If x<0 Or x=Pit.WIDTH Or y=Pit.HEIGHT
+ Return True
+ EndIf
+
+ Local w:TWire=map[x,y]
+
+ If Not w
+ Return False
+ EndIf
+
+ dir=w.Traverse(dir)
+
+ If dir=TWire.DIR_NONE
+ Return False
+ EndIf
+
+ l.Add(x,y,w)
+
+ Return FindPath(l,x+TWire.DirX(dir),y+TWire.DirY(dir),dir)
+ End Method
+
+ Method FindLoop:Int(l:TWireList, ox:Int, oy:Int, x:Int, y:Int, dir:Int)
+ If y<0 Or x<0 Or x=Pit.WIDTH Or y=Pit.HEIGHT
+ Return False
+ EndIf
+
+ Local w:TWire=map[x,y]
+
+ If Not w
+ Return False
+ EndIf
+
+ dir=w.Traverse(dir)
+
+ If dir=TWire.DIR_NONE
+ Return False
+ EndIf
+
+ l.Add(x,y,w)
+
+ x:+TWire.DirX(dir)
+ y:+TWire.DirY(dir)
+
+ If x=ox And y=oy
+ Return True
+ EndIf
+
+ Return FindLoop(l,ox,oy,x,y,dir)
+ End Method
+
+ Method CheckWires()
+ For Local y:Int=0 Until Pit.HEIGHT
+ Local l:TWireList=New TWireList
+
+ If FindPath(l,0,y,TWire.DIR_RIGHT)
+ path.AddLast(l)
+ EndIf
+
+ l=New TWireList
+
+ If FindPath(l,Pit.WIDTH-1,y,TWire.DIR_LEFT)
+ path.AddLast(l)
+ EndIf
+ Next
+
+ For Local x:Int=0 Until Pit.WIDTH
+ Local l:TWireList=New TWireList
+
+ If FindPath(l,x,Pit.HEIGHT-1,TWire.DIR_UP)
+ path.AddLast(l)
+ EndIf
+ Next
+
+ For Local x:Int=0 Until Pit.WIDTH
+ For Local y:Int=0 Until Pit.HEIGHT
+ If map[x,y]
+ 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)
+ path.AddLast(l)
+ EndIf
+ End Select
+ EndIf
+ Next
+ Next
+ 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)
+ End Method
+
+ Method CursorDown()
+ If BlockInteract() Then Return
+ cy=Min(Pit.HEIGHT-2,cy+1)
+ 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
+ EndIf
+ Next
+ Next
+
+ If done
+ Sound.Click()
+ EndIf
+
+ CheckWires()
+ End Method
+
+ Method Draw:Int()
+ Local score:Int=0
+
+ SetColor(255,255,255)
+ DrawImage(GameGFX.pit_bottomleft,Pit.X(-1),Pit.Y(Pit.HEIGHT))
+ DrawImage(GameGFX.pit_bottomright,Pit.X(Pit.WIDTH),Pit.Y(Pit.HEIGHT))
+
+ DrawImage(GameGFX.pit_top,Pit.X(-1),Pit.Y(0))
+ DrawImage(GameGFX.pit_top,Pit.X(Pit.WIDTH),Pit.Y(0))
+ SetColor(trode_col,trode_col,0)
+ DrawImage(GameGFX.trode_left,Pit.X(-1),Pit.Y(0))
+ DrawImage(GameGFX.trode_right,Pit.X(Pit.WIDTH),Pit.Y(0))
+
+ For Local f:Int=0 Until Pit.WIDTH
+ SetColor(255,255,255)
+ DrawImage(GameGFX.pit_bottom,Pit.X(f),Pit.Y(Pit.HEIGHT))
+ SetColor(trode_col,trode_col,0)
+ DrawImage(GameGFX.trode_bottom,Pit.X(f),Pit.Y(Pit.HEIGHT))
+ Next
+
+ For Local f:Int=1 Until Pit.HEIGHT
+ SetColor(255,255,255)
+ DrawImage(GameGFX.pit_side,Pit.X(-1),Pit.Y(f))
+ DrawImage(GameGFX.pit_side,Pit.X(Pit.WIDTH),Pit.Y(f))
+ SetColor(trode_col,trode_col,0)
+ DrawImage(GameGFX.trode_left,Pit.X(-1),Pit.Y(f))
+ DrawImage(GameGFX.trode_right,Pit.X(Pit.WIDTH),Pit.Y(f))
+ Next
+
+ For Local x:Int=0 Until Pit.WIDTH
+ For Local y:Int=0 Until Pit.HEIGHT
+ If map[x,y]
+ SetColor(255,255,255)
+ DrawImage(GameGFX.tile,Pit.X(x),Pit.Y(y))
+ SetColor(128,128,128)
+ DrawImage(map[x,y].Image(),Pit.X(x),Pit.Y(y))
+ EndIf
+ 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)
+
+ 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()
+ EndIf
+ Wend
+
+ If hit And Not overflow
+ Sound.Click()
+ CheckWires()
+ CalcTop()
+ 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)
+ trode_coli=-trode_coli
+ EndIf
+
+ Return score
+ End Method
+End Type
diff --git a/hardwire.bmx b/hardwire.bmx new file mode 100644 index 0000000..61a1180 --- /dev/null +++ b/hardwire.bmx @@ -0,0 +1,255 @@ +' Hardwire
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+
+Import noddybox.bitmapfont
+Import noddybox.keysyms
+Import noddybox.gfxmenu
+
+Import "types.bmx"
+Import "gametypes.bmx"
+Import "game.bmx"
+Import "particle.bmx"
+
+Rem
+TWire.Init()
+For Local t:Int=TWire.CROSS To TWire.BOTTOM_RIGHT
+
+ Local w:TWire=TWire.Create(t)
+
+ For Local d:Int=TWire.DIR_NONE To TWire.DIR_LEFT
+ Print TWire.typename[t] + ": " + TWire.dirname[d] + " -> " + TWire.dirname[w.Traverse(d)]
+ Next
+Next
+End
+EndRem
+
+' ===================================
+' Initialise
+' ===================================
+'
+SeedRnd(MilliSecs())
+
+?Win32
+If Switch("--directx")
+ SetGraphicsDriver D3D7Max2DDriver()
+Else
+ SetGraphicsDriver GLMax2DDriver()
+EndIf
+?
+
+Graphics 800,600,32,60
+HideMouse
+
+SetBlend(ALPHABLEND)
+SetAlpha(1.0)
+
+
+' ===================================
+' Globals
+' ===================================
+'
+GameGFX.Init()
+Lookup.Init()
+GameConfig.Load()
+TWire.Init()
+Particles.Init()
+Sound.Init()
+
+Global bdrop:TMenuBdrop=New TMenuBdrop
+Global quit:Int=False
+
+
+' ===================================
+' Main
+' ===================================
+'
+Menu()
+
+While Not quit
+ Menu()
+Wend
+
+EndGraphics
+End
+
+
+' ===================================
+' Argument Routines
+' ===================================
+'
+Function Switch:Int(s:String)
+ For Local a:String=EachIn AppArgs
+ If a=s
+ Return True
+ EndIf
+ Next
+
+ Return False
+End Function
+
+
+' ===================================
+' Menu Routines
+' ===================================
+'
+Function Menu()
+ Const MENU_PLAY:Int=1
+ Const MENU_QUIT:Int=2
+ Const MENU_SCORES:Int=3
+ Const MENU_KEYS:Int=4
+ Const MENU_LEFT:Int=5
+ Const MENU_RIGHT:Int=6
+
+ Local done:Int=False
+ Local menu:TGfxMenu=TGfxMenu.Create(200,0,0,255,255,255,25,bdrop,1)
+ Local sel:Int
+
+ Local defkey:Int=0
+
+ Local x1:Int=GraphicsWidth()/3-ImageWidth(GameGFX.play_button)/2
+ Local x2:Int=GraphicsWidth()/3*2-ImageWidth(GameGFX.play_button)/2
+
+ menu.Add(x1,150,GameGFX.play_button,MENU_PLAY)
+ menu.Add(x2,150,GameGFX.scores_button,MENU_SCORES)
+ menu.Add(x1,250,GameGFX.keys_button,MENU_KEYS)
+ menu.Add(x2,250,GameGFX.quit_button,MENU_QUIT)
+ menu.Add(x1,350,GameGFX.left_button,MENU_LEFT)
+ menu.Add(x2+ImageWidth(GameGFX.play_button)-ImageWidth(GameGFX.right_button),350,GameGFX.right_button,MENU_RIGHT)
+
+ Local tx1:Int=(GraphicsWidth()-GameGFX.large.TextWidth("START LEVEL 1"))/2
+ Local tx2:Int=tx1+GameGFX.large.TextWidth("START LEVEL ")
+
+ Local gm:TGameMap=New TGameMap
+
+ While Not done
+ If gm.overflow
+ SetClsColor(128,0,0)
+ Else
+ SetClsColor(0,0,0)
+ EndIf
+
+ Cls
+ DrawImage(GameGFX.title,0,0)
+
+ gm.Draw()
+ Particles.Draw()
+
+ sel=menu.Render(defkey>0)
+
+ If defkey>0
+
+ If defkey=7
+ GameGFX.large.Centre("PRESS A KEY TO GO BACK TO THE MENU",150)
+ Else
+ GameGFX.large.Centre("DEFINE KEYS",150)
+ GameGFX.large.Centre("PRESS ESCAPE TO CANCEL",380)
+ EndIf
+
+ Local c1:Int=128+128*(defkey=1)
+ Local c2:Int=128+128*(defkey=2)
+ Local c3:Int=128+128*(defkey=3)
+ Local c4:Int=128+128*(defkey=4)
+ Local c5:Int=128+128*(defkey=5)
+ Local c6:Int=128+128*(defkey=6)
+
+ GameGFX.large.DrawColoured("Left",250,180,c1,c1,0)
+ GameGFX.large.DrawColoured("Right",250,210,c2,c2,0)
+ GameGFX.large.DrawColoured("Up",250,240,c3,c3,0)
+ GameGFX.large.DrawColoured("Down",250,270,c4,c4,0)
+ GameGFX.large.DrawColoured("Rotate",250,300,c5,c5,0)
+ GameGFX.large.DrawColoured("Pause",250,330,c6,c6,0)
+ GameGFX.large.DrawColoured(KeySym(GameConfig.kleft),500,180,c1,c1,0)
+ GameGFX.large.DrawColoured(KeySym(GameConfig.kright),500,210,c2,c2,0)
+ GameGFX.large.DrawColoured(KeySym(GameConfig.kup),500,240,c3,c3,0)
+ GameGFX.large.DrawColoured(KeySym(GameConfig.kdown),500,270,c4,c4,0)
+ GameGFX.large.DrawColoured(KeySym(GameConfig.krot),500,300,c5,c5,0)
+ GameGFX.large.DrawColoured(KeySym(GameConfig.kpause),500,330,c6,c6,0)
+
+
+ Local k:Int=-1
+
+ For Local f:Int=0 To 255
+ If KeyHit(f)
+ k=f
+ Continue
+ EndIf
+ Next
+
+ If k=KEY_ESCAPE
+ GameConfig.Load()
+ defkey=0
+ FlushKeys()
+ ElseIf k<>-1
+ Select defkey
+ Case 1
+ GameConfig.kleft=k
+ Case 2
+ GameConfig.kright=k
+ Case 3
+ GameConfig.kup=k
+ Case 4
+ GameConfig.kdown=k
+ Case 5
+ GameConfig.krot=k
+ Case 6
+ GameConfig.kpause=k
+ End Select
+
+ defkey:+1
+
+ If defkey=7
+ GameConfig.Save()
+ defkey=0
+ FlushKeys()
+ EndIf
+ EndIf
+ Else
+ If KeyHit(KEY_ESCAPE)
+ done=True
+ quit=True
+ EndIf
+
+ GameGFX.large.Draw("START LEVEL ",tx1,356)
+ GameGFX.large.DrawColoured(GameConfig.start_level,tx2,356,255,255,0)
+ EndIf
+
+ Select sel
+ Case MENU_PLAY
+ done=True
+ FlushKeys()
+ Case MENU_SCORES
+ gm.AddRow()
+ FlushKeys()
+ Case MENU_KEYS
+ FlushKeys()
+ defkey=1
+ Case MENU_QUIT
+ done=True
+ quit=True
+ Case MENU_LEFT
+ GameConfig.start_level=Max(1,GameConfig.start_level-1)
+ GameConfig.Save()
+ Case MENU_RIGHT
+ GameConfig.start_level=Min(10,GameConfig.start_level+1)
+ GameConfig.Save()
+ End Select
+
+ Rem
+ SetScale(2,2)
+ GameGFX.font.CentreColoured("HARDWIRE",0,255,255,0)
+
+ SetScale(1,1)
+ GameGFX.font.CentreColoured("Copyright (c) 2005 Ian C",20,255,0,0)
+ EndRem
+
+ SetColor(255,255,255)
+ DrawImage(GameGFX.pointer,MouseX(),MouseY())
+
+ Flip
+ Wend
+End Function
\ No newline at end of file diff --git a/particle.bmx b/particle.bmx new file mode 100644 index 0000000..6269381 --- /dev/null +++ b/particle.bmx @@ -0,0 +1,100 @@ +' Hardwire
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import "types.bmx"
+
+Type TParticle
+ Field life:Int
+ Field i:TImage
+ Field x:Double
+ Field y:Double
+ Field a:Double
+ Field dx:Double
+ Field dy:Double
+ Field ai:Double
+ Field s:Double
+ Field si:double
+
+ Function Dust:TParticle(x:Int, y:Int)
+ Local o:TParticle=New TParticle
+ o.life=50
+ o.x=x
+ o.y=y
+ o.a=1
+ o.ai=-0.05
+ o.dx=0
+ o.dy=0
+ o.s=1
+ o.si=0.1
+ o.i=GameGFX.dust
+ Return o
+ End Function
+
+ Function Image:TParticle(i:TImage, x:Int, y:Int)
+ Local o:TParticle=New TParticle
+ o.life=120
+ o.x=x
+ o.y=y
+ o.a=1
+ o.ai=-0.01
+ o.dx=0
+ o.dy=-0.1
+ o.s=1
+ o.si=0
+ o.i=i
+ Return o
+ End Function
+
+ Method Update:Int()
+ SetAlpha(a)
+ SetScale(s,s)
+ DrawImage(i,x,y)
+ x:+dx
+ y:+dy
+ life:-1
+ a:+ai
+ s:+si
+ Return life>0
+ End Method
+End Type
+
+Type Particles
+ Global plist:TList
+
+ Function Init()
+ plist=CreateList()
+ End Function
+
+ Function Clear()
+ plist.Clear()
+ End Function
+
+ Function AddDust(x:Int, y:Int)
+ plist.AddLast(TParticle.Dust(x,y))
+ End Function
+
+ Function AddImage(i:TImage, x:Int, y:Int)
+ plist.AddLast(TParticle.Image(i,x,y))
+ End Function
+
+ Function Draw()
+ SetColor(255,255,255)
+ Local l:TEasyLink=TEasyLink.Create(plist)
+
+ While l.Value()
+ Local p:TParticle=TParticle(l.Value())
+
+ If (p.Update())
+ l.MoveNext()
+ Else
+ l.Remove()
+ EndIf
+ Wend
+ SetAlpha(1)
+ SetScale(1,1)
+ End Function
+End Type
diff --git a/sounds.bmx b/sounds.bmx new file mode 100644 index 0000000..b33ccec --- /dev/null +++ b/sounds.bmx @@ -0,0 +1,35 @@ +' Hardwire
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+
+Incbin "SFX/pop.wav"
+Incbin "SFX/click.wav"
+Incbin "SFX/path.wav"
+
+Type Sound
+ Global popsfx:TSound
+ Global clicksfx:TSound
+ Global pathsfx:TSound
+
+ Function Init()
+ popsfx=LoadSound("incbin::SFX/pop.wav")
+ clicksfx=LoadSound("incbin::SFX/click.wav")
+ pathsfx=LoadSound("incbin::SFX/path.wav")
+ End Function
+
+ Function Pop()
+ popsfx.Play()
+ End Function
+
+ Function Click()
+ clicksfx.Play()
+ End Function
+
+ Function Path()
+ pathsfx.Play()
+ End Function
+End Type
diff --git a/types.bmx b/types.bmx new file mode 100644 index 0000000..62d08dd --- /dev/null +++ b/types.bmx @@ -0,0 +1,295 @@ +' Hardwire
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import noddybox.bitmapfont
+Import noddybox.gfxmenu
+
+
+' Included binaries
+'
+Incbin "GFX/font.bmf"
+Incbin "GFX/small.bmf"
+Incbin "GFX/large.bmf"
+Incbin "GFX/pointer.png"
+Incbin "GFX/play_button.png"
+Incbin "GFX/quit_button.png"
+Incbin "GFX/scores_button.png"
+Incbin "GFX/keys_button.png"
+Incbin "GFX/left_button.png"
+Incbin "GFX/right_button.png"
+Incbin "GFX/copper.png"
+Incbin "GFX/copperslice.png"
+Incbin "GFX/dust.png"
+Incbin "GFX/title.png"
+Incbin "GFX/cursor.png"
+
+Incbin "TILES/tile.png"
+Incbin "TILES/pit_top.png"
+Incbin "TILES/pit_bottomleft.png"
+Incbin "TILES/pit_bottomright.png"
+Incbin "TILES/pit_bottom.png"
+Incbin "TILES/pit_side.png"
+Incbin "TILES/trode_left.png"
+Incbin "TILES/trode_right.png"
+Incbin "TILES/trode_bottom.png"
+Incbin "TILES/top_bottom.png"
+Incbin "TILES/left_right.png"
+Incbin "TILES/cross.png"
+Incbin "TILES/top_left.png"
+Incbin "TILES/top_right.png"
+Incbin "TILES/bottom_left.png"
+Incbin "TILES/bottom_right.png"
+
+Type Lookup
+ Global si:Double[]
+ Global co:Double[]
+
+ Function Init()
+ si=New Double[360]
+ co=New Double[360]
+
+ For Local a:Int=0 To 359
+ si[a]=Sin(a)
+ co[a]=Cos(a)
+ Next
+ End Function
+End Type
+
+
+Type GameGFX
+ Global font:TBitmapFont
+ Global small:TBitmapFont
+ Global large:TBitmapFont
+
+ Global title:TImage
+
+ Global pointer:TImage
+ Global copper:TImage
+ Global copperslice:TImage
+ Global dust:TImage
+
+ Global play_button:TImage
+ Global quit_button:TImage
+ Global left_button:TImage
+ Global right_button:TImage
+ Global scores_button:TImage
+ Global keys_button:TImage
+
+ Global cursor:TImage
+ Global tile:TImage
+
+ Global pit_top:TImage
+ Global pit_bottomleft:TImage
+ Global pit_bottomright:TImage
+ Global pit_bottom:TImage
+ Global pit_side:TImage
+
+ Global trode_left:TImage
+ Global trode_right:TImage
+ Global trode_bottom:TImage
+
+ Global top_bottom:Timage
+ Global left_right:Timage
+ Global cross:Timage
+ Global top_left:Timage
+ Global top_right:Timage
+ Global bottom_left:Timage
+ Global bottom_right:Timage
+
+ Function Init()
+ font=TBitmapFont.Load("incbin::GFX/font.bmf",0)
+ small=TBitmapFont.Load("incbin::GFX/small.bmf",0)
+ large=TBitmapFont.Load("incbin::GFX/large.bmf",0)
+
+ title=LoadImage("incbin::GFX/title.png",0)
+
+ pointer=LoadImage("incbin::GFX/pointer.png",0)
+
+ copper=LoadImage("incbin::GFX/copper.png",0)
+ copperslice=LoadImage("incbin::GFX/copperslice.png",0)
+
+ dust=LoadImage("incbin::GFX/dust.png",FILTEREDIMAGE)
+ MidHandleImage(dust)
+
+ play_button=LoadImage("incbin::GFX/play_button.png",0)
+ quit_button=LoadImage("incbin::GFX/quit_button.png",0)
+ scores_button=LoadImage("incbin::GFX/scores_button.png",0)
+ keys_button=LoadImage("incbin::GFX/keys_button.png",0)
+ left_button=LoadImage("incbin::GFX/left_button.png",0)
+ right_button=LoadImage("incbin::GFX/right_button.png",0)
+
+ tile=LoadImage("incbin::TILES/tile.png",0)
+ cursor=LoadImage("incbin::GFX/cursor.png",0)
+
+ pit_top=LoadImage("incbin::TILES/pit_top.png",0)
+ pit_bottom=LoadImage("incbin::TILES/pit_bottom.png",0)
+ pit_bottomleft=LoadImage("incbin::TILES/pit_bottomleft.png",0)
+ pit_bottomright=LoadImage("incbin::TILES/pit_bottomright.png",0)
+ pit_side=LoadImage("incbin::TILES/pit_side.png",0)
+
+ trode_left=LoadImage("incbin::TILES/trode_left.png",0)
+ trode_right=LoadImage("incbin::TILES/trode_right.png",0)
+ trode_bottom=LoadImage("incbin::TILES/trode_bottom.png",0)
+
+ top_bottom=LoadImage("incbin::TILES/top_bottom.png",0)
+ left_right=LoadImage("incbin::TILES/left_right.png",0)
+ cross=LoadImage("incbin::TILES/cross.png",0)
+ top_left=LoadImage("incbin::TILES/top_left.png",0)
+ top_right=LoadImage("incbin::TILES/top_right.png",0)
+ bottom_left=LoadImage("incbin::TILES/bottom_left.png",0)
+ bottom_right=LoadImage("incbin::TILES/bottom_right.png",0)
+ End Function
+End Type
+
+Type GameConfig
+ Global kleft:Int
+ Global kright:Int
+ Global kup:Int
+ Global kdown:Int
+ Global krot:Int
+ Global kpause:Int
+ Global start_level:Int
+
+ Function Load()
+ Local s:TStream=ReadStream("hardwire.config")
+
+ If s=Null
+ kleft=KEY_LEFT
+ kright=KEY_RIGHT
+ kup=KEY_UP
+ kdown=KEY_DOWN
+ krot=KEY_SPACE
+ kpause=KEY_P
+ start_level=1
+ Return
+ EndIf
+
+ s=LittleEndianStream(s)
+
+ kleft=s.ReadInt()
+ kright=s.ReadInt()
+ kup=s.ReadInt()
+ kdown=s.ReadInt()
+ krot=s.ReadInt()
+ kpause=s.ReadInt()
+ start_level=s.ReadInt()
+
+ s.Close()
+ End Function
+
+ Function Save()
+ Local s:TStream=WriteStream("hardwire.config")
+
+ If s=Null
+ Return
+ EndIf
+
+ s=LittleEndianStream(s)
+
+ s.WriteInt(kleft)
+ s.WriteInt(kright)
+ s.WriteInt(kup)
+ s.WriteInt(kdown)
+ s.WriteInt(krot)
+ s.WriteInt(kpause)
+ s.WriteInt(start_level)
+
+ s.Close()
+ End Function
+EndType
+
+Type TEasyLink
+ Field l:TLink
+
+ Function Create:TEasyLink(l:TList)
+ Local o:TEasyLink=New TEasyLink
+ o.l=l.FirstLink()
+ Return o
+ End Function
+
+ Method Value:Object()
+ If l
+ Return l.Value()
+ Else
+ Return Null
+ EndIf
+ End Method
+
+ Method MoveNext()
+ If l
+ l=l.NextLink()
+ EndIf
+ End Method
+
+ Method Remove()
+ Local ol:TLink=l
+ MoveNext()
+ ol.Remove()
+ End Method
+End Type
+
+
+Type TMenuBdrop Extends TGfxMenuBackdrop
+ Const NUM:Int=2
+ Const SIZE:Double=50.0
+ Const OFFSET:Double=500.0
+ Field a:Int[NUM]
+ Field msg:String
+ Field msgp:Int
+ Field msgx:Int
+ Field msgy:Int
+
+ Method New()
+ For Local f:Int=0 Until NUM
+ a[f]=360/NUM*f
+ Next
+
+ msg=" "
+ msg:+"Welcome to Hardwire. The object of the game is to connect the electrodes around the side of the pit using "
+ msg:+"the wires embedded in the blocks. Once a circuit is completed those blocks are removed. Once in a while new blocks will fall from the sky. "
+ msg:+"If you let the pit overflow the game is over. That's all there is to it... "
+ msg:+"Hardwire was written using BlitzMax -- http://www.blitzbasic.com/ -- and a variety of tools available at "
+ msg:+"http://www.noddybox.demon.co.uk/ Please feel free to forward this game on to whoever you despise enough "
+ msg:+"to inflict this monstrosity upon. Enjoy."
+
+ msgx=0
+ msgp=0
+ msgy=OFFSET
+ End Method
+
+ Method Create:TGfxMenuBackdrop()
+ Return Self
+ End Method
+
+ Method Update()
+ For Local f:Int=0 Until NUM
+ a[f]=(a[f]+2) Mod 360
+
+ If a[f]<=180
+ Local c:Int=128-Abs(64*Lookup.si[a[f]])
+ SetColor(c,c,c)
+ DrawImage(GameGFX.copper,0,OFFSET+SIZE*Lookup.co[a[f]])
+ EndIf
+ Next
+
+ GameGFX.large.Draw(msg[..80],msgx,msgy)
+ msgx:-2
+ If msgx<-GameGFX.large.TextWidth(msg[0..1])
+ msgx:+GameGFX.large.TextWidth(msg[0..1])
+ msg=msg[1..]+msg[0..1]
+ EndIf
+
+ For Local f:Int=0 Until NUM
+ If a[f]>180
+ Local c:Int=128+Abs(64*Lookup.si[a[f]])
+ SetColor(c,c,c)
+ DrawImage(GameGFX.copper,0,OFFSET+SIZE*Lookup.co[a[f]])
+ EndIf
+ Next
+ SetColor(255,255,255)
+ End Method
+End Type
|