' Missile Lock ' ' Copyright (C) 2006 Ian Cowburn (ianc@noddybox.co.uk) ' ' This program is free software; you can redistribute it and/or modify ' it under the terms of the GNU General Public License as published by ' the Free Software Foundation; either version 2 of the License, or ' (at your option) any later version. ' ' This program is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU General Public License for more details. ' ' You should have received a copy of the GNU General Public License ' along with this program; if not, write to the Free Software ' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ' ' ------------------------------------------------------------------------- ' ' $Id$ ' Strict Framework brl.basic Import brl.max2d Import brl.glmax2d ?Win32 Import brl.d3d7max2d ? Import noddybox.bitmapfont Import noddybox.keysyms Import "global.bmx" Import "gametypes.bmx" 'Import "game.bmx" Import "particle.bmx" 'Import "help.bmx" ' =================================== ' Initialise ' =================================== ' SeedRnd(MilliSecs()) ?Win32 If Switch("--directx") SetGraphicsDriver D3D7Max2DDriver() Else SetGraphicsDriver GLMax2DDriver() EndIf ? Graphics 800,600,32,HERTZ SetOrigin(400,300) HideMouse SetBlend(ALPHABLEND) SetAlpha(1.0) ' =================================== ' Globals ' =================================== ' GFX.Init() ' MUST be first Lookup.Init() GameConfig.Load() Scroller.Init() Particles.Init() GameState.Reset() Global quit:Int=False ' =================================== ' Main ' =================================== ' Menu() While Not quit GameState.Reset() TFadeScreen.DoFadeOut() GameConfig.Save() 'last_score=game.score 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() Local fade:TFadeScreen=TFadeScreen.FadeIn() Local done:Int=False Local defkey:Int=0 Particles.Clear() While Not done Cls If Rand(100)>30 Particles.AddScaledImage(GFX.exhaust,Rand(-400,400),Rand(-400,400),0.3) End If GameState.ang=(GameState.ang+2) Mod 3600 SetOrigin(400,300) Particles.Draw() GameState.Display() Scroller.Draw() SetOrigin(0,0) SetColor(255,255,255) DrawImage(GFX.title,0,0) If defkey>0 If defkey=5 GFX.font.Centre("PRESS A KEY TO GO BACK TO THE MENU",380) Else GFX.font.Centre("DEFINE KEYS",350) GFX.font.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) GFX.font.Draw("LEFT",250,200,c1,c1,c1) GFX.font.Draw("RIGHT",250,220,c2,c2,c2) GFX.font.Draw("FIRE",250,240,c3,c3,c3) GFX.font.Draw("PAUSE",250,260,c4,c4,c4) GFX.font.Draw(KeySym(GameConfig.kleft),500,200,c1,c1,0) GFX.font.Draw(KeySym(GameConfig.kright),500,220,c2,c2,0) GFX.font.Draw(KeySym(GameConfig.kfire),500,240,c3,c3,0) GFX.font.Draw(KeySym(GameConfig.kpause),500,260,c4,c4,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.kfire=k Case 4 GameConfig.kpause=k End Select defkey:+1 If defkey=6 GameConfig.Save() defkey=0 FlushKeys() EndIf EndIf Else If KeyHit(KEY_ESCAPE) done=True quit=True EndIf If KeyHit(KEY_SPACE) done=True EndIf If KeyHit(KEY_R) defkey=1 FlushKeys() EndIf GFX.font.Centre("COPYRIGHT (C) NODDYBOX 2006",200) GFX.font.Centre("PRESS FIRE TO PLAY",300) GFX.font.Centre("PRESS R TO REDEFINE KEYS",380) GFX.font.Centre("PRESS ESCAPE TO QUIT",400) EndIf If fade If fade.Fade() fade.Draw() Else fade=Null EndIf EndIf Flip Wend Particles.Clear() TFadeScreen.DoFadeOut() SetOrigin(400,300) End Function