diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-11-15 23:47:10 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-11-15 23:47:10 +0000 |
commit | 80225fead703db9a5ffed86b1bd3fb004e3005aa (patch) | |
tree | ac026295b5a326b92b548a845478536f8db5a63e /vectoroids.bmx | |
parent | 2a0e7de95036f380a5729328c10ba86eb6e001ba (diff) |
Added pause mode
Diffstat (limited to 'vectoroids.bmx')
-rw-r--r-- | vectoroids.bmx | 411 |
1 files changed, 205 insertions, 206 deletions
diff --git a/vectoroids.bmx b/vectoroids.bmx index 69563f9..b4018bc 100644 --- a/vectoroids.bmx +++ b/vectoroids.bmx @@ -1,206 +1,205 @@ -' Vectoroids -' -' Copyright 2005 Ian Cowburn -' -' $Id$ -' -Strict - -Import noddybox.vector -Import noddybox.bitmapfont -Import noddybox.keysyms - -Import "types.bmx" -Import "game.bmx" -Import "sounds.bmx" -Import "hiscore.bmx" - - -' 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 -' -Lookup.Init() -GameGFX.Init() -TParticleMachine.Init() -GameConfig.Load() -Sounds.Init() - -Global quit:Int=False -Global hiscore:THiscore=THiscore.Load() - -' Main code -' -Menu() - -While Not quit - Local game:TGame=New TGame - While game.Play() - Wend - Sounds.Clear() - TParticleMachine.Clear() - hiscore.Check(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() - FlushKeys() - - Local done:Int=False - - Local defkey:Int=0 - Local obj:TVectorGfxObject - - Select Rand(1,2) - Case 1 - obj=GameGFX.large.Clone() - Case 2 - obj=GameGFX.ship.Clone() - End Select - - obj.scale=5 - obj.x=GraphicsWidth()/2 - obj.y=GraphicsHeight()/2 - - While Not done - If KeyHit(KEY_ESCAPE) - done=True - quit=True - EndIf - - Cls - - obj.ang=(obj.ang+1) Mod 3600 - - If defkey=0 - SetAlpha(0.5) - Else - SetAlpha(0.2) - EndIf - SetColor(255,255,255) - obj.Draw() - SetAlpha(1) - - If defkey>0 - - If defkey=7 - GameGFX.font.Centre("PRESS A KEY TO GO BACK TO THE MENU",120) - Else - GameGFX.font.Centre("DEFINE KEYS",120) - EndIf - - GameGFX.font.DrawColoured("left",250,150,255,255*(defkey=1),0) - GameGFX.font.DrawColoured("right",250,170,255,255*(defkey=2),0) - GameGFX.font.DrawColoured("thrust",250,190,255,255*(defkey=3),0) - GameGFX.font.DrawColoured("fire",250,210,255,255*(defkey=4),0) - GameGFX.font.DrawColoured("hyperspace",250,230,255,255*(defkey=5),0) - GameGFX.font.DrawColoured("pause",250,250,255,255*(defkey=6),0) - GameGFX.font.DrawColoured(KeySym(GameConfig.kleft).ToLower(),500,150,255,255*(defkey=1),0) - GameGFX.font.DrawColoured(KeySym(GameConfig.kright).ToLower(),500,170,255,255*(defkey=2),0) - GameGFX.font.DrawColoured(KeySym(GameConfig.kthrust).ToLower(),500,190,255,255*(defkey=3),0) - GameGFX.font.DrawColoured(KeySym(GameConfig.kfire).ToLower(),500,210,255,255*(defkey=4),0) - GameGFX.font.DrawColoured(KeySym(GameConfig.khyper).ToLower(),500,230,255,255*(defkey=5),0) - GameGFX.font.DrawColoured(KeySym(GameConfig.kpause).ToLower(),500,250,255,255*(defkey=6),0) - - Local k:Int=0 - - For Local f:Int=1 To 255 - If KeyHit(f) - k=f - Continue - EndIf - Next - - If k<>0 - Select defkey - Case 1 - GameConfig.kleft=k - Case 2 - GameConfig.kright=k - Case 3 - GameConfig.kthrust=k - Case 4 - GameConfig.kfire=k - Case 5 - GameConfig.khyper=k - Case 6 - GameConfig.kpause=k - End Select - - defkey:+1 - - If defkey=8 - GameConfig.Save() - defkey=0 - EndIf - EndIf - Else - GameGFX.font.CentreColoured("vectoroids",0,255,255,0) - GameGFX.font.CentreColoured("COPYRIGHT | 2005 IAN C",20,255,0,0) - - GameGFX.font.Centre("press space to play",150) - GameGFX.font.Centre("press r to redefine keys",190) - GameGFX.font.Centre("EXTRA LIFE AT 10000 PTS THEN EVERY 50000 PTS",520) - GameGFX.font.Centre("ESCAPE TO QUIT",560) - GameGFX.font.CentreColoured("BASED ON ASTEROIDS | 1979 ~~ ATARI INC.",580,255,0,0) - - hiscore.Display(400) - - If KeyHit(KEY_ESCAPE) - done=True - quit=True - EndIf - - If KeyHit(KEY_R) - FlushKeys() - defkey=1 - EndIf - - If KeyHit(KEY_SPACE) - FlushKeys() - done=True - EndIf - EndIf - - Flip - FlushMem - Wend -End Function +' Vectoroids
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+
+Import noddybox.vector
+Import noddybox.bitmapfont
+Import noddybox.keysyms
+
+Import "types.bmx"
+Import "game.bmx"
+Import "sounds.bmx"
+Import "hiscore.bmx"
+
+
+' 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
+'
+Lookup.Init()
+GameGFX.Init()
+TParticleMachine.Init()
+GameConfig.Load()
+Sounds.Init()
+
+Global quit:Int=False
+Global hiscore:THiscore=THiscore.Load()
+
+' Main code
+'
+Menu()
+
+While Not quit
+ Local game:TGame=New TGame
+ While game.Play()
+ Wend
+ Sounds.Clear()
+ TParticleMachine.Clear()
+ hiscore.Check(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()
+ FlushKeys()
+
+ Local done:Int=False
+
+ Local defkey:Int=0
+ Local obj:TVectorGfxObject
+
+ Select Rand(1,2)
+ Case 1
+ obj=GameGFX.large.Clone()
+ Case 2
+ obj=GameGFX.ship.Clone()
+ End Select
+
+ obj.scale=5
+ obj.x=GraphicsWidth()/2
+ obj.y=GraphicsHeight()/2
+
+ While Not done
+ If KeyHit(KEY_ESCAPE)
+ done=True
+ quit=True
+ EndIf
+
+ Cls
+
+ obj.ang=(obj.ang+1) Mod 3600
+
+ If defkey=0
+ SetAlpha(0.5)
+ Else
+ SetAlpha(0.2)
+ EndIf
+ SetColor(255,255,255)
+ obj.Draw()
+ SetAlpha(1)
+
+ If defkey>0
+
+ If defkey=7
+ GameGFX.font.Centre("PRESS A KEY TO GO BACK TO THE MENU",120)
+ Else
+ GameGFX.font.Centre("DEFINE KEYS",120)
+ EndIf
+
+ GameGFX.font.DrawColoured("left",250,150,255,255*(defkey=1),0)
+ GameGFX.font.DrawColoured("right",250,170,255,255*(defkey=2),0)
+ GameGFX.font.DrawColoured("thrust",250,190,255,255*(defkey=3),0)
+ GameGFX.font.DrawColoured("fire",250,210,255,255*(defkey=4),0)
+ GameGFX.font.DrawColoured("hyperspace",250,230,255,255*(defkey=5),0)
+ GameGFX.font.DrawColoured("pause",250,250,255,255*(defkey=6),0)
+ GameGFX.font.DrawColoured(KeySym(GameConfig.kleft).ToLower(),500,150,255,255*(defkey=1),0)
+ GameGFX.font.DrawColoured(KeySym(GameConfig.kright).ToLower(),500,170,255,255*(defkey=2),0)
+ GameGFX.font.DrawColoured(KeySym(GameConfig.kthrust).ToLower(),500,190,255,255*(defkey=3),0)
+ GameGFX.font.DrawColoured(KeySym(GameConfig.kfire).ToLower(),500,210,255,255*(defkey=4),0)
+ GameGFX.font.DrawColoured(KeySym(GameConfig.khyper).ToLower(),500,230,255,255*(defkey=5),0)
+ GameGFX.font.DrawColoured(KeySym(GameConfig.kpause).ToLower(),500,250,255,255*(defkey=6),0)
+
+ Local k:Int=0
+
+ For Local f:Int=1 To 255
+ If KeyHit(f)
+ k=f
+ Continue
+ EndIf
+ Next
+
+ If k<>0
+ Select defkey
+ Case 1
+ GameConfig.kleft=k
+ Case 2
+ GameConfig.kright=k
+ Case 3
+ GameConfig.kthrust=k
+ Case 4
+ GameConfig.kfire=k
+ Case 5
+ GameConfig.khyper=k
+ Case 6
+ GameConfig.kpause=k
+ End Select
+
+ defkey:+1
+
+ If defkey=8
+ GameConfig.Save()
+ defkey=0
+ EndIf
+ EndIf
+ Else
+ GameGFX.font.CentreColoured("vectoroids",0,255,255,0)
+ GameGFX.font.CentreColoured("COPYRIGHT | 2005 IAN C",20,255,0,0)
+
+ GameGFX.font.Centre("press space to play",150)
+ GameGFX.font.Centre("press r to redefine keys",190)
+ GameGFX.font.Centre("EXTRA LIFE AT 10000 PTS THEN EVERY 50000 PTS",520)
+ GameGFX.font.Centre("ESCAPE TO QUIT",560)
+ GameGFX.font.CentreColoured("BASED ON ASTEROIDS | 1979 ~~ ATARI INC.",580,255,0,0)
+
+ hiscore.Display(400)
+
+ If KeyHit(KEY_ESCAPE)
+ done=True
+ quit=True
+ EndIf
+
+ If KeyHit(KEY_R)
+ FlushKeys()
+ defkey=1
+ EndIf
+
+ If KeyHit(KEY_SPACE)
+ FlushKeys()
+ done=True
+ EndIf
+ EndIf
+
+ Flip
+ Wend
+End Function
|