' 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 HideMouse SetBlend(ALPHABLEND) SetAlpha(1.0) ' =================================== ' Globals ' =================================== ' GFX.Init() ' MUST be first Lookup.Init() GameConfig.Load() Scroller.Init() Particles.Init() Backdrop.Init() Trail.Init() Global quit:Int=False ' =================================== ' Main ' =================================== ' Menu() While Not quit GameState.Reset() While Not KeyHit(KEY_ESCAPE) Cls Backdrop.Draw() Particles.Draw() Trail.Draw() GameState.Display() GameState.Control() GameState.Move() SetRotation(GameState.ang) DrawImage(GFX.ship,GameState.x,GameState.y) SetRotation(0) Flip(1) Wend GameConfig.Save() TFadeScreen.DoFadeOut() 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() GameState.Reset() While Not done Cls If Rand(100)>30 Particles.AddScaledImage(GFX.exhaust,Rand(0,800),Rand(0,600),0.3) End If Backdrop.Draw() Particles.Draw() GameState.Display() Scroller.Draw() SetColor(255,255,255) DrawImage(GFX.title,0,0) If defkey>0 If defkey=4 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) GFX.font.Draw("LEFT",250,200,c1,c1,c1) GFX.font.Draw("RIGHT",250,220,c2,c2,c2) GFX.font.Draw("PAUSE",250,240,c3,c3,c3) 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.kpause),500,240,c3,c3,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.kpause=k End Select defkey:+1 If defkey=5 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 SPACE 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(1) Wend Particles.Clear() TFadeScreen.DoFadeOut() End Function