diff options
-rw-r--r-- | global.bmx | 811 | ||||
-rw-r--r-- | missile_lock.bmx | 976 |
2 files changed, 894 insertions, 893 deletions
@@ -1,405 +1,406 @@ -' 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 -Import brl.pngloader - -Import noddybox.bitmapfont -Import noddybox.gfxmenu - - -' Included binaries -' -Incbin "GFX/font.bmf" - -Incbin "GFX/title.png" -Incbin "GFX/ship.png" -Incbin "GFX/missile.png" -Incbin "GFX/exhaust.png" -Incbin "GFX/flame.png" -Incbin "GFX/star.png" -Incbin "GFX/twinkle.png" -Incbin "GFX/asteroid.png" -Incbin "GFX/fireball.png" - -Const HERTZ:Int=70 - -Const MISSILE_LAYER:Int=1 -Const ASTEROID_LAYER:Int=2 -Const ALL_LAYERS:Int=3 - -Type GFX - Global font:TBitmapFont - - Global title:TImage - - Global ship:TImage - Global missile:TImage - Global exhaust:TImage - Global flame:TImage - Global star:TImage - Global twinkle:TImage - Global asteroid:TImage - Global fireball:TImage - - Function SafeLoadImage:TImage(p:String, mode:Int) - Local i:TImage=LoadImage(p,mode) - Assert i,"Failed to load " + p - Return i - End Function - - Function SafeLoadAnimImage:TImage(p:String, w:Int, h:Int, f:Int, c:Int, mode:Int) - Local i:TImage=LoadAnimImage(p,w,h,f,c,mode) - Assert i,"Failed to load " + p - Return i - End Function - - Function Init() - font=TBitmapFont.Load("incbin::GFX/font.bmf",0) - - Assert font,"Failed to load incbin::GFX/font.bmf" - - title=SafeLoadImage("incbin::GFX/title.png",0) - - ship=SafeLoadImage("incbin::GFX/ship.png",FILTEREDIMAGE) - flame=SafeLoadImage("incbin::GFX/flame.png",FILTEREDIMAGE) - MidHandleImage(ship) - MidHandleImage(flame) - - missile=SafeLoadImage("incbin::GFX/missile.png",FILTEREDIMAGE) - exhaust=SafeLoadImage("incbin::GFX/exhaust.png",FILTEREDIMAGE) - SetImageHandle(missile,3,7) - SetImageHandle(exhaust,3,3) - - star=SafeLoadImage("incbin::GFX/star.png",0) - SetImageHandle(star,1,1) - - twinkle=SafeLoadAnimImage("incbin::GFX/twinkle.png",8,8,0,6,0) - SetImageHandle(star,2,2) - - asteroid=SafeLoadImage("incbin::GFX/asteroid.png",FILTEREDIMAGE) - MidHandleImage(asteroid) - - fireball=SafeLoadImage("incbin::GFX/fireball.png",FILTEREDIMAGE) - SetImageHandle(fireball,15,15) - End Function -End Type - -Type GameConfig - Global kleft:Int - Global kright:Int - Global kpause:Int - Global kthrust:Int - Global hiscore:Int - Global maxlevel:Int - Global accepted:Int - - Function Load() - Local s:TStream=ReadStream("mlock.config") - - If s=Null - kleft=KEY_LEFT - kright=KEY_RIGHT - kthrust=KEY_SPACE - kpause=KEY_P - hiscore=0 - maxlevel=1 - accepted=False - Return - EndIf - - s=LittleEndianStream(s) - - kleft=s.ReadInt() - kright=s.ReadInt() - kthrust=s.ReadInt() - kpause=s.ReadInt() - hiscore=s.ReadInt() - maxlevel=s.ReadInt() - accepted=s.ReadInt() - - s.Close() - End Function - - Function Save() - Local s:TStream=WriteStream("mlock.config") - - If s=Null - Return - EndIf - - s=LittleEndianStream(s) - - s.WriteInt(kleft) - s.WriteInt(kright) - s.WriteInt(kthrust) - s.WriteInt(kpause) - s.WriteInt(hiscore) - s.WriteInt(maxlevel) - s.WriteInt(accepted) - - 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 Scroller - Global msg:String - Global msgp:Int - Global msgx:Int - Global txth:Int - - Function Init() - Rem - msg=" " - msg:+"DURING A TEST-FLIGHT OF THE STAR-FIGHTER OGL-X YOU ARE AMBUSHED IN THE ASTEROID FIELD OUTSIDE OF MARS... " - msg:+"THE EVIL EMPIRE CANNOT BE ALLOWED TO DESTROY THE PROTOTYPE SO YOU MUST PILOT THE WEAPONLESS CRAFT, " - msg:+"AVOIDING THE DEADLY MISSILES UNTIL HELP ARRIVES... " - msg:+"SHOW HEART YOUNG PILOT, STAR-FLEET IS DEPENDING UPON YOU!" - EndRem - - msg=" " - msg:+"IT IS A TIME OF WAR. IN A LAST DITCH ATTEMPT TO WIN A LOSING WAR THAT HAS RAGED THROUGH THE GALAXY AGAINST THE EVIL EMPIRE " - msg:+"A NEW SHIP, THE DX-9, HAS BEEN DEVELOPED. ON A ROUTINE TEST FLIGHT THE SHIP HAS BEEN AMBUSHED IN AN ASTEROID FIELD. " - msg:+"WEAPONLESS, YOU MUST PILOT THE DX-9 AND AVOID THE EMPIRE'S MISSILE SALVOS AMONGST THE ASTEROIDS... HELP WILL ARRIVE EVENTUALLY, " - msg:+"BUT UNTIL THEN YOU ARE OUR LAST HOPE. IF THE DX-9 IS LOST THEN SO IS THE EARTH. EARTH IS DEPENDING ON YOU!!!" - - msgx=0 - msgp=0 - - txth=GFX.font.MaxHeight() - End Function - - Function Draw(y:Int) - GFX.font.Draw(msg[..70],msgx,y) - - Rem - SetColor(0,0,0) - Local a:Double=1 - For Local f:Int=0 To 10 - SetAlpha(a) - a:-0.09 - DrawLine(f,y,f,y+txth) - DrawLine(799-f,y,799-f,y+txth) - Next - SetColor(255,255,255) - SetAlpha(1) - EndRem - - msgx:-2 - If msgx<-GFX.font.TextWidth(msg[0..1]) - msgx:+GFX.font.TextWidth(msg[0..1]) - msg=msg[1..]+msg[0..1] - EndIf - End Function -End Type - -Type VText - Field t:String - Field y:Int - - Function Create:VText(t:String, y:Int) - Local o:VText=New VText - o.t=t - o.y=y - Return o - End Function -End Type - -Type VerticalScroller - Global msg:TList - Global maxy:Int - - Method New() - msg=CreateList() - maxy=0 - End Method - - Method Add(s:String) - SetScale(2,2) - msg.AddLast(VText.Create(s,maxy+800)) - maxy:+GFX.font.TextHeight(s) - SetScale(1,1) - End Method - - Method Draw() - SetScale(2,2) - For Local o:VText=EachIn msg - o.y:-1 - If o.y<-GFX.font.TextHeight(o.t) - o.y:+maxy - EndIf - If o.y<799 - GFX.font.Centre(o.t,o.y) - EndIf - Next - SetScale(1,1) - End Method -End Type - -Type Thanks - Global item:String[] - Global i:Int - Global wait:Int - Global a:Double - Global ai:Double - - Function Init() - item=["HTTP://WWW.SLAYRADIO.ORG/", .. - "HTTP://WWW.BLITZBASIC.COM/"] - i=0 - a=0 - ai=0.05 - End Function - - Function Draw(y:Int) - SetAlpha(a) - GFX.font.Centre(item[i],y) - SetAlpha(1) - - If wait - wait:-1 - Else - a:+ai - - If a>1 - wait=HERTZ*5 - ai=-0.05 - a=1 - ElseIf a<0 - i=(i+1) Mod item.length - ai=0.05 - a=0 - EndIf - EndIf - End Function -End Type - -Type TFadeScreen - Field a:Double - Field ai:Double - - Function Create:TFadeScreen(a:Double, ai:Double) - Local o:TFadeScreen=New TFadeScreen - o.a=a - o.ai=ai - Return o - End Function - - Function FadeOut:TFadeScreen() - Return Create(0,0.05) - End Function - - Function FadeIn:TFadeScreen() - Return Create(1,-0.05) - End Function - - Function DoFadeIn() - Local fade:TFadeScreen=TFadeScreen.FadeIn() - Local pm:TPixmap=GrabPixmap(0,0,GraphicsWidth(),GraphicsHeight()) - - While fade.Fade() - Cls - DrawPixmap(pm,0,0) - fade.Draw() - Flip - Wend - End Function - - Function DoFadeOut() - Local fade:TFadeScreen=TFadeScreen.FadeOut() - Local pm:TPixmap=GrabPixmap(0,0,GraphicsWidth(),GraphicsHeight()) - - While fade.Fade() - Cls - DrawPixmap(pm,0,0) - fade.Draw() - Flip - Wend - End Function - - Method Fade:Int() - a:+ai - Return a>0 And a<1 - End Method - - Method Draw() - Local r:Int,g:Int,b:Int - Local x:Float,y:Float - Local oa:Double=GetAlpha() - GetColor(r,g,b) - GetOrigin(x,y) - SetAlpha(a) - SetColor(0,0,0) - DrawRect(-x,-y,GraphicsWidth(),GraphicsHeight()) - SetColor(r,g,b) - SetAlpha(oa) - End Method -End Type - - -Type Number - Function Format:String(num:Int) - Local c:Int=0 - Local ret:String="" - Local a:String=String.FromInt(num) - - For Local f:Int=a.length-1 To 0 Step -1 - If ret.length And (c Mod 3)=0 - ret=","+ret - EndIf - ret=a[f..f+1]+ret - c:+1 - Next - Return ret - End Function -End Type +' 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
+Import brl.pngloader
+Import brl.timerdefault
+
+Import noddybox.bitmapfont
+Import noddybox.gfxmenu
+
+
+' Included binaries
+'
+Incbin "GFX/font.bmf"
+
+Incbin "GFX/title.png"
+Incbin "GFX/ship.png"
+Incbin "GFX/missile.png"
+Incbin "GFX/exhaust.png"
+Incbin "GFX/flame.png"
+Incbin "GFX/star.png"
+Incbin "GFX/twinkle.png"
+Incbin "GFX/asteroid.png"
+Incbin "GFX/fireball.png"
+
+Const HERTZ:Int=70
+
+Const MISSILE_LAYER:Int=1
+Const ASTEROID_LAYER:Int=2
+Const ALL_LAYERS:Int=3
+
+Type GFX
+ Global font:TBitmapFont
+
+ Global title:TImage
+
+ Global ship:TImage
+ Global missile:TImage
+ Global exhaust:TImage
+ Global flame:TImage
+ Global star:TImage
+ Global twinkle:TImage
+ Global asteroid:TImage
+ Global fireball:TImage
+
+ Function SafeLoadImage:TImage(p:String, mode:Int)
+ Local i:TImage=LoadImage(p,mode)
+ Assert i,"Failed to load " + p
+ Return i
+ End Function
+
+ Function SafeLoadAnimImage:TImage(p:String, w:Int, h:Int, f:Int, c:Int, mode:Int)
+ Local i:TImage=LoadAnimImage(p,w,h,f,c,mode)
+ Assert i,"Failed to load " + p
+ Return i
+ End Function
+
+ Function Init()
+ font=TBitmapFont.Load("incbin::GFX/font.bmf",0)
+
+ Assert font,"Failed to load incbin::GFX/font.bmf"
+
+ title=SafeLoadImage("incbin::GFX/title.png",0)
+
+ ship=SafeLoadImage("incbin::GFX/ship.png",FILTEREDIMAGE)
+ flame=SafeLoadImage("incbin::GFX/flame.png",FILTEREDIMAGE)
+ MidHandleImage(ship)
+ MidHandleImage(flame)
+
+ missile=SafeLoadImage("incbin::GFX/missile.png",FILTEREDIMAGE)
+ exhaust=SafeLoadImage("incbin::GFX/exhaust.png",FILTEREDIMAGE)
+ SetImageHandle(missile,3,7)
+ SetImageHandle(exhaust,3,3)
+
+ star=SafeLoadImage("incbin::GFX/star.png",0)
+ SetImageHandle(star,1,1)
+
+ twinkle=SafeLoadAnimImage("incbin::GFX/twinkle.png",8,8,0,6,0)
+ SetImageHandle(star,2,2)
+
+ asteroid=SafeLoadImage("incbin::GFX/asteroid.png",FILTEREDIMAGE)
+ MidHandleImage(asteroid)
+
+ fireball=SafeLoadImage("incbin::GFX/fireball.png",FILTEREDIMAGE)
+ SetImageHandle(fireball,15,15)
+ End Function
+End Type
+
+Type GameConfig
+ Global kleft:Int
+ Global kright:Int
+ Global kpause:Int
+ Global kthrust:Int
+ Global hiscore:Int
+ Global maxlevel:Int
+ Global accepted:Int
+
+ Function Load()
+ Local s:TStream=ReadStream("mlock.config")
+
+ If s=Null
+ kleft=KEY_LEFT
+ kright=KEY_RIGHT
+ kthrust=KEY_SPACE
+ kpause=KEY_P
+ hiscore=0
+ maxlevel=1
+ accepted=False
+ Return
+ EndIf
+
+ s=LittleEndianStream(s)
+
+ kleft=s.ReadInt()
+ kright=s.ReadInt()
+ kthrust=s.ReadInt()
+ kpause=s.ReadInt()
+ hiscore=s.ReadInt()
+ maxlevel=s.ReadInt()
+ accepted=s.ReadInt()
+
+ s.Close()
+ End Function
+
+ Function Save()
+ Local s:TStream=WriteStream("mlock.config")
+
+ If s=Null
+ Return
+ EndIf
+
+ s=LittleEndianStream(s)
+
+ s.WriteInt(kleft)
+ s.WriteInt(kright)
+ s.WriteInt(kthrust)
+ s.WriteInt(kpause)
+ s.WriteInt(hiscore)
+ s.WriteInt(maxlevel)
+ s.WriteInt(accepted)
+
+ 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 Scroller
+ Global msg:String
+ Global msgp:Int
+ Global msgx:Int
+ Global txth:Int
+
+ Function Init()
+ Rem
+ msg=" "
+ msg:+"DURING A TEST-FLIGHT OF THE STAR-FIGHTER OGL-X YOU ARE AMBUSHED IN THE ASTEROID FIELD OUTSIDE OF MARS... "
+ msg:+"THE EVIL EMPIRE CANNOT BE ALLOWED TO DESTROY THE PROTOTYPE SO YOU MUST PILOT THE WEAPONLESS CRAFT, "
+ msg:+"AVOIDING THE DEADLY MISSILES UNTIL HELP ARRIVES... "
+ msg:+"SHOW HEART YOUNG PILOT, STAR-FLEET IS DEPENDING UPON YOU!"
+ EndRem
+
+ msg=" "
+ msg:+"IT IS A TIME OF WAR. IN A LAST DITCH ATTEMPT TO WIN A LOSING WAR THAT HAS RAGED THROUGH THE GALAXY AGAINST THE EVIL EMPIRE "
+ msg:+"A NEW SHIP, THE DX-9, HAS BEEN DEVELOPED. ON A ROUTINE TEST FLIGHT THE SHIP HAS BEEN AMBUSHED IN AN ASTEROID FIELD. "
+ msg:+"WEAPONLESS, YOU MUST PILOT THE DX-9 AND AVOID THE EMPIRE'S MISSILE SALVOS AMONGST THE ASTEROIDS... HELP WILL ARRIVE EVENTUALLY, "
+ msg:+"BUT UNTIL THEN YOU ARE OUR LAST HOPE. IF THE DX-9 IS LOST THEN SO IS THE EARTH. EARTH IS DEPENDING ON YOU!!!"
+
+ msgx=0
+ msgp=0
+
+ txth=GFX.font.MaxHeight()
+ End Function
+
+ Function Draw(y:Int)
+ GFX.font.Draw(msg[..70],msgx,y)
+
+ Rem
+ SetColor(0,0,0)
+ Local a:Double=1
+ For Local f:Int=0 To 10
+ SetAlpha(a)
+ a:-0.09
+ DrawLine(f,y,f,y+txth)
+ DrawLine(799-f,y,799-f,y+txth)
+ Next
+ SetColor(255,255,255)
+ SetAlpha(1)
+ EndRem
+
+ msgx:-2
+ If msgx<-GFX.font.TextWidth(msg[0..1])
+ msgx:+GFX.font.TextWidth(msg[0..1])
+ msg=msg[1..]+msg[0..1]
+ EndIf
+ End Function
+End Type
+
+Type VText
+ Field t:String
+ Field y:Int
+
+ Function Create:VText(t:String, y:Int)
+ Local o:VText=New VText
+ o.t=t
+ o.y=y
+ Return o
+ End Function
+End Type
+
+Type VerticalScroller
+ Global msg:TList
+ Global maxy:Int
+
+ Method New()
+ msg=CreateList()
+ maxy=0
+ End Method
+
+ Method Add(s:String)
+ SetScale(2,2)
+ msg.AddLast(VText.Create(s,maxy+800))
+ maxy:+GFX.font.TextHeight(s)
+ SetScale(1,1)
+ End Method
+
+ Method Draw()
+ SetScale(2,2)
+ For Local o:VText=EachIn msg
+ o.y:-1
+ If o.y<-GFX.font.TextHeight(o.t)
+ o.y:+maxy
+ EndIf
+ If o.y<799
+ GFX.font.Centre(o.t,o.y)
+ EndIf
+ Next
+ SetScale(1,1)
+ End Method
+End Type
+
+Type Thanks
+ Global item:String[]
+ Global i:Int
+ Global wait:Int
+ Global a:Double
+ Global ai:Double
+
+ Function Init()
+ item=["HTTP://WWW.SLAYRADIO.ORG/", ..
+ "HTTP://WWW.BLITZMAX.ORG/"]
+ i=0
+ a=0
+ ai=0.05
+ End Function
+
+ Function Draw(y:Int)
+ SetAlpha(a)
+ GFX.font.Centre(item[i],y)
+ SetAlpha(1)
+
+ If wait
+ wait:-1
+ Else
+ a:+ai
+
+ If a>1
+ wait=HERTZ*5
+ ai=-0.05
+ a=1
+ ElseIf a<0
+ i=(i+1) Mod item.length
+ ai=0.05
+ a=0
+ EndIf
+ EndIf
+ End Function
+End Type
+
+Type TFadeScreen
+ Field a:Double
+ Field ai:Double
+
+ Function Create:TFadeScreen(a:Double, ai:Double)
+ Local o:TFadeScreen=New TFadeScreen
+ o.a=a
+ o.ai=ai
+ Return o
+ End Function
+
+ Function FadeOut:TFadeScreen()
+ Return Create(0,0.05)
+ End Function
+
+ Function FadeIn:TFadeScreen()
+ Return Create(1,-0.05)
+ End Function
+
+ Function DoFadeIn()
+ Local fade:TFadeScreen=TFadeScreen.FadeIn()
+ Local pm:TPixmap=GrabPixmap(0,0,GraphicsWidth(),GraphicsHeight())
+
+ While fade.Fade()
+ Cls
+ DrawPixmap(pm,0,0)
+ fade.Draw()
+ Flip(-1)
+ Wend
+ End Function
+
+ Function DoFadeOut()
+ Local fade:TFadeScreen=TFadeScreen.FadeOut()
+ Local pm:TPixmap=GrabPixmap(0,0,GraphicsWidth(),GraphicsHeight())
+
+ While fade.Fade()
+ Cls
+ DrawPixmap(pm,0,0)
+ fade.Draw()
+ Flip(-1)
+ Wend
+ End Function
+
+ Method Fade:Int()
+ a:+ai
+ Return a>0 And a<1
+ End Method
+
+ Method Draw()
+ Local r:Int,g:Int,b:Int
+ Local x:Float,y:Float
+ Local oa:Double=GetAlpha()
+ GetColor(r,g,b)
+ GetOrigin(x,y)
+ SetAlpha(a)
+ SetColor(0,0,0)
+ DrawRect(-x,-y,GraphicsWidth(),GraphicsHeight())
+ SetColor(r,g,b)
+ SetAlpha(oa)
+ End Method
+End Type
+
+
+Type Number
+ Function Format:String(num:Int)
+ Local c:Int=0
+ Local ret:String=""
+ Local a:String=String.FromInt(num)
+
+ For Local f:Int=a.length-1 To 0 Step -1
+ If ret.length And (c Mod 3)=0
+ ret=","+ret
+ EndIf
+ ret=a[f..f+1]+ret
+ c:+1
+ Next
+ Return ret
+ End Function
+End Type
diff --git a/missile_lock.bmx b/missile_lock.bmx index b8575ec..1ec92f3 100644 --- a/missile_lock.bmx +++ b/missile_lock.bmx @@ -1,488 +1,488 @@ -' 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 noddybox.showlicense - -Import "global.bmx" -Import "gametypes.bmx" -'Import "game.bmx" -Import "particle.bmx" -'Import "help.bmx" -Import "sound.bmx" - -Incbin "short_license.txt" -Incbin "license.txt" - -' =================================== -' 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 -SFX.Init() - -GameConfig.Load() - -If Not GameConfig.accepted - If Not ShowLicense("MISSILE LOCK -- LICENSE","incbin::short_license.txt","incbin::license.txt") - EndGraphics() - End - EndIf - GameConfig.accepted=True - GameConfig.Save() -EndIf - -Scroller.Init() -Thanks.Init() -Particles.Init() -Backdrop.Init() -Trail.Init() -MissileSet.Init() -AsteroidSet.Init() - -Global quit:Int=False -Global start_level:Int=1 - - -' =================================== -' Main -' =================================== -' -Menu() - -FlushKeys() - -While Not quit - Local start_bonus:Int=1000*(start_level-1) - - GameState.Reset() - GameState.SetLevel(start_level) - MissileSet.StartLevel() - AsteroidSet.StartLevel() - - While Not GameState.game_over - - Local alert_timer:Int=200 - - SFX.Alert() - - While Not GameState.game_over And Not MissileSet.AllDestroyed() - Cls() - - If alert_timer - alert_timer:-1 - If alert_timer Mod 60 < 30 - GFX.font.Centre("RED ALERT!",300,255,0,0) - EndIf - EndIf - - ResetCollisions() - - Backdrop.Draw() - Particles.Draw() - Trail.Draw() - - GameState.Control() - GameState.Move() - - SetRotation(GameState.ang) - - If GameState.shield - SetColor(Rand(0,255),Rand(0,255),Rand(0,255)) - Else - SetColor(255,255,255) - EndIf - - DrawImage(GFX.ship,GameState.x,GameState.y) - SetRotation(0) - - MissileSet.Update() - AsteroidSet.Update() - - Local col:Object[]=CollideImage(GFX.ship,GameState.x,GameState.y,0,ALL_LAYERS,0) - - If Not GameState.shield Then - If col - GameState.ShieldDown() - Particles.AddExplosion(GameState.x,GameState.y) - For Local m:Missile=EachIn col - If m - MissileSet.RemoveMissile(m) - GameState.AddScore(1*GameState.level) - Exit - EndIf - Next - EndIf - EndIf - - If GameState.pause - GFX.font.Centre("PAUSED!",300,255,255,0) - EndIf - - GameState.Display() - Flip(1) - - If GameState.pause - GameState.pause=False - While Not KeyHit(GameConfig.kpause) And Not KeyHit(KEY_ESCAPE) - Wend - EndIf - Wend - - If Not GameState.game_over - AsteroidSet.Nuke() - - Local bonus=100*GameState.level - Local added:Int=0 - Local timer:Int=Max(HERTZ*5,bonus/10+HERTZ*3) - Local bt:Int=0 - - If GameState.gonads - GameState.AddScore(9999+(GameState.level-1)*10000) - EndIf - - If Not GameState.hit - GameState.AddScore(500*GameState.level) - EndIf - - If start_bonus - GameState.AddScore(start_bonus) - EndIf - - If GameState.bonus_timer - bonus:+GameState.bonus_timer - bt=GameState.bonus_timer - EndIf - - GameState.bonus_timer=0 - - While timer And Not KeyHit(KEY_ESCAPE) - Cls() - ResetCollisions() - - GameState.ShieldShip() - - Backdrop.Draw() - Particles.Draw() - Trail.Draw() - - GameState.Control() - GameState.Move() - - SetRotation(GameState.ang) - - If GameState.shield - SetColor(Rand(0,255),Rand(0,255),Rand(0,255)) - Else - SetColor(255,255,255) - EndIf - - DrawImage(GFX.ship,GameState.x,GameState.y) - SetRotation(0) - - GFX.font.Centre("LEVEL " + GameState.level + " COMPLETED!",200,255,255,0) - - GFX.font.Centre("BONUS " + Number.Format(added) + "!!!",400,255,255,0) - - If bt - GFX.font.Centre("TIMER BONUS " + bt + "!!!",420,255,255,0) - EndIf - - Local y:Int=440 - - If Not GameState.hit - GFX.font.Centre("PERFECT BONUS " + (500*GameState.level) + "!!!",y,255,255,0) - y:+20 - EndIf - - If start_bonus - GFX.font.Centre("STARTING LEVEL BONUS " + start_bonus + "!!!",y,255,255,0) - y:+20 - EndIf - - If GameState.gonads - GFX.font.Centre("SECRET GONADS OF STEEL BONUS " + (9999+(GameState.level-1)*10000) + "!!!",y,255,255,0) - y:+20 - EndIf - - If added<bonus - GameState.AddScore(10) - added:+10 - EndIf - - If timer<HERTZ*2 - GFX.font.Centre("GET READY!",300) - EndIf - - If GameState.pause - GFX.font.Centre("PAUSED!",300,255,255,0) - EndIf - - GameState.Display() - Flip(1) - - If GameState.pause - GameState.pause=False - While Not KeyHit(GameConfig.kpause) And Not KeyHit(KEY_ESCAPE) - Wend - EndIf - - timer:-1 - Wend - - start_bonus=0 - - GameState.AddScore(bonus-added) - - GameState.LevelUp() - MissileSet.StartLevel() - AsteroidSet.StartLevel() - EndIf - Wend - - GameConfig.maxlevel=Max(GameState.level,GameConfig.maxlevel) - - GameConfig.Save() - - MissileSet.Nuke() - AsteroidSet.Nuke() - Particles.AddBigExplosion(GameState.x,GameState.y) - - FlushKeys() - Local timer:Int=0 - - While Not KeyHit(KEY_SPACE) And Not KeyHit(KEY_ESCAPE) And timer<HERTZ*5 - Cls() - - Backdrop.Draw() - Particles.Draw() - Trail.Draw() - - GameState.Display() - - SetScale(3,3) - GFX.font.Centre("GAME OVER!",280) - SetScale(1,1) - Flip(1) - - timer:+1 - Wend - - 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() - - While Not done - Cls - - Rem - If Rand(100)>90 - Local x:Int=Rand(0,800) - Local y:Int=Rand(0,600) - Particles.AddScaledImage(GFX.fireball,x,y,0.1) - End If - End Rem - - Backdrop.Draw() - Particles.Draw() - Scroller.Draw(560) - - 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("THRUST",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.kthrust),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.kthrust=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(GameConfig.kthrust) - done=True - EndIf - - If KeyHit(KEY_R) - defkey=1 - FlushKeys() - EndIf - - If GameConfig.maxlevel>1 - If KeyHit(KEY_LEFT) Or KeyHit(KEY_DOWN) - start_level=start_level-1 - If start_level<1 - start_level=GameConfig.maxlevel - EndIf - ElseIf KeyHit(KEY_RIGHT) Or KeyHit(KEY_UP) - start_level=start_level+1 - If start_level>GameConfig.maxlevel - start_level=1 - EndIf - End If - EndIf - - GFX.font.Centre("COPYRIGHT (C) NODDYBOX 2006",200) - GFX.font.Centre("HTTP://WWW.NODDYBOX.CO.UK/",226) - - GFX.font.Centre("THANKS TO",300) - Thanks.Draw(326) - - GFX.font.Centre("PRESS " + KeySym(GameConfig.kthrust).ToUpper() + " TO PLAY",400) - - If GameConfig.maxlevel>1 - GFX.font.Centre("CURSORS TO SELECT STARTING LEVEL: "+start_level,450) - EndIf - - GFX.font.Centre("PRESS R TO REDEFINE KEYS",480) - GFX.font.Centre("PRESS ESCAPE TO QUIT",500) - EndIf - - If fade - If fade.Fade() - fade.Draw() - Else - fade=Null - EndIf - EndIf - - GameState.Display() - Flip(1) - Wend - - Particles.Clear() - TFadeScreen.DoFadeOut() -End Function +' 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 noddybox.showlicense
+
+Import "global.bmx"
+Import "gametypes.bmx"
+'Import "game.bmx"
+Import "particle.bmx"
+'Import "help.bmx"
+Import "sound.bmx"
+
+Incbin "short_license.txt"
+Incbin "license.txt"
+
+' ===================================
+' Initialise
+' ===================================
+'
+SeedRnd(MilliSecs())
+
+?Win32
+If Switch("--directx")
+ SetGraphicsDriver D3D7Max2DDriver()
+Else
+ SetGraphicsDriver GLMax2DDriver()
+EndIf
+?
+
+Graphics 800,600,32
+HideMouse
+
+SetBlend(ALPHABLEND)
+SetAlpha(1.0)
+
+
+' ===================================
+' Globals
+' ===================================
+'
+GFX.Init() ' MUST be first
+SFX.Init()
+
+GameConfig.Load()
+
+If Not GameConfig.accepted
+ If Not ShowLicense("MISSILE LOCK -- LICENSE","incbin::short_license.txt","incbin::license.txt")
+ EndGraphics()
+ End
+ EndIf
+ GameConfig.accepted=True
+ GameConfig.Save()
+EndIf
+
+Scroller.Init()
+Thanks.Init()
+Particles.Init()
+Backdrop.Init()
+Trail.Init()
+MissileSet.Init()
+AsteroidSet.Init()
+
+Global quit:Int=False
+Global start_level:Int=1
+
+
+' ===================================
+' Main
+' ===================================
+'
+Menu()
+
+FlushKeys()
+
+While Not quit
+ Local start_bonus:Int=1000*(start_level-1)
+
+ GameState.Reset()
+ GameState.SetLevel(start_level)
+ MissileSet.StartLevel()
+ AsteroidSet.StartLevel()
+
+ While Not GameState.game_over
+
+ Local alert_timer:Int=200
+
+ SFX.Alert()
+
+ While Not GameState.game_over And Not MissileSet.AllDestroyed()
+ Cls()
+
+ If alert_timer
+ alert_timer:-1
+ If alert_timer Mod 60 < 30
+ GFX.font.Centre("RED ALERT!",300,255,0,0)
+ EndIf
+ EndIf
+
+ ResetCollisions()
+
+ Backdrop.Draw()
+ Particles.Draw()
+ Trail.Draw()
+
+ GameState.Control()
+ GameState.Move()
+
+ SetRotation(GameState.ang)
+
+ If GameState.shield
+ SetColor(Rand(0,255),Rand(0,255),Rand(0,255))
+ Else
+ SetColor(255,255,255)
+ EndIf
+
+ DrawImage(GFX.ship,GameState.x,GameState.y)
+ SetRotation(0)
+
+ MissileSet.Update()
+ AsteroidSet.Update()
+
+ Local col:Object[]=CollideImage(GFX.ship,GameState.x,GameState.y,0,ALL_LAYERS,0)
+
+ If Not GameState.shield Then
+ If col
+ GameState.ShieldDown()
+ Particles.AddExplosion(GameState.x,GameState.y)
+ For Local m:Missile=EachIn col
+ If m
+ MissileSet.RemoveMissile(m)
+ GameState.AddScore(1*GameState.level)
+ Exit
+ EndIf
+ Next
+ EndIf
+ EndIf
+
+ If GameState.pause
+ GFX.font.Centre("PAUSED!",300,255,255,0)
+ EndIf
+
+ GameState.Display()
+ Flip(-1)
+
+ If GameState.pause
+ GameState.pause=False
+ While Not KeyHit(GameConfig.kpause) And Not KeyHit(KEY_ESCAPE)
+ Wend
+ EndIf
+ Wend
+
+ If Not GameState.game_over
+ AsteroidSet.Nuke()
+
+ Local bonus=100*GameState.level
+ Local added:Int=0
+ Local timer:Int=Max(HERTZ*5,bonus/10+HERTZ*3)
+ Local bt:Int=0
+
+ If GameState.gonads
+ GameState.AddScore(9999+(GameState.level-1)*10000)
+ EndIf
+
+ If Not GameState.hit
+ GameState.AddScore(500*GameState.level)
+ EndIf
+
+ If start_bonus
+ GameState.AddScore(start_bonus)
+ EndIf
+
+ If GameState.bonus_timer
+ bonus:+GameState.bonus_timer
+ bt=GameState.bonus_timer
+ EndIf
+
+ GameState.bonus_timer=0
+
+ While timer And Not KeyHit(KEY_ESCAPE)
+ Cls()
+ ResetCollisions()
+
+ GameState.ShieldShip()
+
+ Backdrop.Draw()
+ Particles.Draw()
+ Trail.Draw()
+
+ GameState.Control()
+ GameState.Move()
+
+ SetRotation(GameState.ang)
+
+ If GameState.shield
+ SetColor(Rand(0,255),Rand(0,255),Rand(0,255))
+ Else
+ SetColor(255,255,255)
+ EndIf
+
+ DrawImage(GFX.ship,GameState.x,GameState.y)
+ SetRotation(0)
+
+ GFX.font.Centre("LEVEL " + GameState.level + " COMPLETED!",200,255,255,0)
+
+ GFX.font.Centre("BONUS " + Number.Format(added) + "!!!",400,255,255,0)
+
+ If bt
+ GFX.font.Centre("TIMER BONUS " + bt + "!!!",420,255,255,0)
+ EndIf
+
+ Local y:Int=440
+
+ If Not GameState.hit
+ GFX.font.Centre("PERFECT BONUS " + (500*GameState.level) + "!!!",y,255,255,0)
+ y:+20
+ EndIf
+
+ If start_bonus
+ GFX.font.Centre("STARTING LEVEL BONUS " + start_bonus + "!!!",y,255,255,0)
+ y:+20
+ EndIf
+
+ If GameState.gonads
+ GFX.font.Centre("SECRET GONADS OF STEEL BONUS " + (9999+(GameState.level-1)*10000) + "!!!",y,255,255,0)
+ y:+20
+ EndIf
+
+ If added<bonus
+ GameState.AddScore(10)
+ added:+10
+ EndIf
+
+ If timer<HERTZ*2
+ GFX.font.Centre("GET READY!",300)
+ EndIf
+
+ If GameState.pause
+ GFX.font.Centre("PAUSED!",300,255,255,0)
+ EndIf
+
+ GameState.Display()
+ Flip(-1)
+
+ If GameState.pause
+ GameState.pause=False
+ While Not KeyHit(GameConfig.kpause) And Not KeyHit(KEY_ESCAPE)
+ Wend
+ EndIf
+
+ timer:-1
+ Wend
+
+ start_bonus=0
+
+ GameState.AddScore(bonus-added)
+
+ GameState.LevelUp()
+ MissileSet.StartLevel()
+ AsteroidSet.StartLevel()
+ EndIf
+ Wend
+
+ GameConfig.maxlevel=Max(GameState.level,GameConfig.maxlevel)
+
+ GameConfig.Save()
+
+ MissileSet.Nuke()
+ AsteroidSet.Nuke()
+ Particles.AddBigExplosion(GameState.x,GameState.y)
+
+ FlushKeys()
+ Local timer:Int=0
+
+ While Not KeyHit(KEY_SPACE) And Not KeyHit(KEY_ESCAPE) And timer<HERTZ*5
+ Cls()
+
+ Backdrop.Draw()
+ Particles.Draw()
+ Trail.Draw()
+
+ GameState.Display()
+
+ SetScale(3,3)
+ GFX.font.Centre("GAME OVER!",280)
+ SetScale(1,1)
+ Flip(-1)
+
+ timer:+1
+ Wend
+
+ 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()
+
+ While Not done
+ Cls
+
+ Rem
+ If Rand(100)>90
+ Local x:Int=Rand(0,800)
+ Local y:Int=Rand(0,600)
+ Particles.AddScaledImage(GFX.fireball,x,y,0.1)
+ End If
+ End Rem
+
+ Backdrop.Draw()
+ Particles.Draw()
+ Scroller.Draw(560)
+
+ 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("THRUST",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.kthrust),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.kthrust=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(GameConfig.kthrust)
+ done=True
+ EndIf
+
+ If KeyHit(KEY_R)
+ defkey=1
+ FlushKeys()
+ EndIf
+
+ If GameConfig.maxlevel>1
+ If KeyHit(KEY_LEFT) Or KeyHit(KEY_DOWN)
+ start_level=start_level-1
+ If start_level<1
+ start_level=GameConfig.maxlevel
+ EndIf
+ ElseIf KeyHit(KEY_RIGHT) Or KeyHit(KEY_UP)
+ start_level=start_level+1
+ If start_level>GameConfig.maxlevel
+ start_level=1
+ EndIf
+ End If
+ EndIf
+
+ GFX.font.Centre("COPYRIGHT (C) NODDYBOX 2006",200)
+ GFX.font.Centre("HTTP://WWW.NODDYBOX.CO.UK/",226)
+
+ GFX.font.Centre("THANKS TO",300)
+ Thanks.Draw(326)
+
+ GFX.font.Centre("PRESS " + KeySym(GameConfig.kthrust).ToUpper() + " TO PLAY",400)
+
+ If GameConfig.maxlevel>1
+ GFX.font.Centre("CURSORS TO SELECT STARTING LEVEL: "+start_level,450)
+ EndIf
+
+ GFX.font.Centre("PRESS R TO REDEFINE KEYS",480)
+ GFX.font.Centre("PRESS ESCAPE TO QUIT",500)
+ EndIf
+
+ If fade
+ If fade.Fade()
+ fade.Draw()
+ Else
+ fade=Null
+ EndIf
+ EndIf
+
+ GameState.Display()
+ Flip(-1)
+ Wend
+
+ Particles.Clear()
+ TFadeScreen.DoFadeOut()
+End Function
|