From 8dbb5e4ab32cc2e0d105f51fde19dedb5b2bb2bc Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 22 Nov 2005 00:46:56 +0000 Subject: Initial import --- hardwire.bmx | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 hardwire.bmx (limited to 'hardwire.bmx') 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 -- cgit v1.2.3