From d23bfbafcae77cfe0dacea61db578c91a70b8c32 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 12 Oct 2007 23:41:49 +0000 Subject: Updates for update blitz --- game.bmx | 788 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 394 insertions(+), 394 deletions(-) (limited to 'game.bmx') diff --git a/game.bmx b/game.bmx index 8b88300..5fe68ba 100644 --- a/game.bmx +++ b/game.bmx @@ -1,394 +1,394 @@ -' Vectoroids -' -' Copyright 2005 Ian Cowburn -' -' $Id$ -' -Strict -Import noddybox.vector -Import noddybox.bitmapfont -Import noddybox.vectorgfx -Import "types.bmx" -Import "sounds.bmx" - -Type TGame - - Field score:Int - Field astlist:TList - Field bullets:TList - Field lives:Int - Field ship:TVectorGfxObject - Field lifeship:TVectorGfxObject - Field shotdelay:Int - Field deaddelay:Int - Field x:Double - Field y:Double - Field dx:Double - Field dy:Double - Field waiting:Int - Field freq:Int - Field hit:Int - Field hyperdelay:Int - Field waitdelay:Int - Field leveldelay:Int - Field minspeed:Double - Field maxspeed:Double - Field numast:Int - Field extralife:Int - Field saucerdelay:Int - Field saucertime:Int - Field saucershot:Int - Field saucer:TSaucer - - Method New() - score=0 - astlist=CreateList() - bullets=CreateList() - lives=2 - ship=GameGFX.ship.Clone() - lifeship=GameGFX.ship.Clone() - deaddelay=250 - waiting=True - waitdelay=500 - x=GraphicsWidth()/2 - y=GraphicsHeight()/2 - dx=0 - dy=0 - ship.ang=0 - ship.x=x - ship.y=y - leveldelay=0 - extralife=10000 - - lifeship.y=5 - lifeship.scale=0.5 - - minspeed=0.1 - maxspeed=1.0 - numast=5 - - saucertime=120*50 - saucerdelay=0 - saucershot=150 - - NewLevel() - End Method - - Method NewLevel() - TAsteroid.minspeed=minspeed - TAsteroid.maxspeed=maxspeed - For Local f:Int=0 Until numast - astlist.AddLast(TAsteroid.Create()) - Next - freq=30 - hit=0 - bullets.Clear() - shotdelay=0 - hyperdelay=0 - End Method - - Method CheckShipLaunch() - Local x1:Int=GraphicsWidth()/2-100 - Local y1:Int=GraphicsHeight()/2-100 - Local x2:Int=GraphicsWidth()/2+100 - Local y2:Int=GraphicsHeight()/2+100 - - If waitdelay=0 Or KeyHit(GameConfig.khyper) - FlushKeys() - waiting=False - EndIf - - waitdelay:-1 - - For Local a:TAsteroid=EachIn astlist - If saucer Or (a.x>x1 And a.xy1 And a.y0 - ac[f]:-1 - Else - a[f]:+1 - EndIf - al:+0.1 - Next - - SetRotation(0) - SetScale(1,1) - GameGFX.font.Centre("paused",GraphicsHeight()/2-16) - - Flip - Wend - - SetAlpha(1) - SetRotation(0) - SetScale(1,1) - - FlushKeys - Sounds.EndPause() - End Method - - Method Play:Int() - Cls - - If waiting And lives>=0 - CheckShipLaunch() - EndIf - - If astlist.Count()=0 - If leveldelay=0 - leveldelay=200 - Else - leveldelay:-1 - If leveldelay=0 - numast=Min(20,numast+2) - minspeed=Min(0.5,minspeed+0.05) - maxspeed=Min(2.0,maxspeed+0.05) - saucertime=Max(10,saucertime-20) - saucershot=Max(25,saucershot-10) - NewLevel() - EndIf - EndIf - EndIf - - If lives>-1 And saucer=Null - saucerdelay:+1 - - If saucerdelay>saucertime - saucerdelay=0 - If score<10000 - saucer=TSaucer.Create(True,saucershot) - ElseIf score<20000 - saucer=TSaucer.Create(Rand(0,1),saucershot) - Else - saucer=TSaucer.Create(False,saucershot) - EndIf - EndIf - EndIf - - - If lives>-1 And Not waiting - If KeyDown(GameConfig.kleft) - ship.ang:-20 - If ship.ang<0 - ship.ang:+3600 - EndIf - EndIf - - If KeyDown(GameConfig.kright) - ship.ang=(ship.ang+20) Mod 3600 - EndIf - - If KeyDown(GameConfig.kthrust) - Sounds.PlayerThrust(True) - dx=Min(2,Max(-2,dx+Lookup.si[ship.ang]*0.1)) - dy=Min(2,Max(-2,dy+Lookup.co[ship.ang]*0.1)) - Else - Sounds.PlayerThrust(False) - EndIf - - If KeyDown(GameConfig.khyper) And hyperdelay=0 - x=Rand(10,GraphicsWidth()-10) - y=Rand(10,GraphicsHeight()-10) - dx=0 - dy=0 - hyperdelay=100 - EndIf - - If KeyDown(GameConfig.kfire) And shotdelay=0 - Sounds.PlayerFire() - bullets.AddLast(TShot.Create(ship)) - shotdelay=25 - EndIf - - If shotdelay>0 - shotdelay:-1 - EndIf - - If hyperdelay>0 - hyperdelay:-1 - EndIf - - If KeyHit(KEY_ESCAPE) - lives=-1 - TParticleMachine.AsteroidExplosion(ship.x,ship.y) - Sounds.ShipExplosion() - EndIf - - x:+dx - y:+dy - - If x<0 - x:+GraphicsWidth() - EndIf - - If x>=GraphicsWidth() - x:-GraphicsWidth() - EndIf - - If y<0 - y:+GraphicsHeight() - EndIf - - If y>=GraphicsHeight() - y:-GraphicsHeight() - EndIf - - ship.x=x - ship.y=y - EndIf - - SetAlpha(0.7) - - For Local a:TAsteroid=EachIn astlist - a.Update() - Next - - For Local f:Int=1 To lives - lifeship.x=f*9 - lifeship.Draw() - Next - - SetAlpha(1) - - GameGFX.font.Centre(score,0) - SetColor(255,255,255) - If lives<0 - For Local s:TShot=EachIn bullets - s.Update(bullets,astlist,saucer) - Next - Else - For Local s:TShot=EachIn bullets - Local sc:Int=s.Update(bullets,astlist,saucer) - score:+sc - - If sc - If score>extralife - If extralife=10000 - extralife=50000 - Else - extralife:+50000 - EndIf - lives:+1 - Sounds.ExtraLife() - EndIf - - hit:+1 - If hit>3 - hit=0 - If freq>15 - freq:-1 - EndIf - EndIf - EndIf - Next - EndIf - - Local hit:Int=False - - If saucer - SetAlpha(0.7) - If lives>-1 And Not waiting - hit=saucer.Update(ship) - Else - saucer.Update(Null) - EndIf - - SetAlpha(1) - - If saucer.Finished() - saucer=Null - Sounds.NoSaucer() - EndIf - EndIf - - If lives<0 - deaddelay:-1 - GameGFX.font.Centre("game over",292) - Else - If Not waiting - SetAlpha(0.7) - - If hit Or Collides(ship.DrawToPointList()) - TParticleMachine.ShipExplosion(ship.x,ship.y) - Sounds.ShipExplosion() - - lives:-1 - x=GraphicsWidth()/2 - y=GraphicsHeight()/2 - dx=0 - dy=0 - ship.ang=0 - ship.x=x - ship.y=y - waiting=True - waitdelay=500 - FlushKeys() - EndIf - - SetAlpha(1) - EndIf - EndIf - - TParticleMachine.Process() - Sounds.Update(freq) - - Flip - - If KeyHit(GameConfig.kpause) - Pause() - EndIf - - Return deaddelay>0 - End Method - - Method Collides:Int(list:TList) - For Local a:TAsteroid=EachIn astlist - For Local p:TVectorGfxPoint=EachIn list - If a.obj.IsInside(p.x,p.y) - Return True - EndIf - Next - Next - - Return False - End Method - -End Type +' Vectoroids +' +' Copyright 2005 Ian Cowburn +' +' $Id$ +' +Strict +Import noddybox.vector +Import noddybox.bitmapfont +Import noddybox.vectorgfx +Import "types.bmx" +Import "sounds.bmx" + +Type TGame + + Field score:Int + Field astlist:TList + Field bullets:TList + Field lives:Int + Field ship:TVectorGfxObject + Field lifeship:TVectorGfxObject + Field shotdelay:Int + Field deaddelay:Int + Field x:Double + Field y:Double + Field dx:Double + Field dy:Double + Field waiting:Int + Field freq:Int + Field hit:Int + Field hyperdelay:Int + Field waitdelay:Int + Field leveldelay:Int + Field minspeed:Double + Field maxspeed:Double + Field numast:Int + Field extralife:Int + Field saucerdelay:Int + Field saucertime:Int + Field saucershot:Int + Field saucer:TSaucer + + Method New() + score=0 + astlist=CreateList() + bullets=CreateList() + lives=2 + ship=GameGFX.ship.Clone() + lifeship=GameGFX.ship.Clone() + deaddelay=250 + waiting=True + waitdelay=500 + x=GraphicsWidth()/2 + y=GraphicsHeight()/2 + dx=0 + dy=0 + ship.ang=0 + ship.x=x + ship.y=y + leveldelay=0 + extralife=10000 + + lifeship.y=5 + lifeship.scale=0.5 + + minspeed=0.1 + maxspeed=1.0 + numast=5 + + saucertime=120*50 + saucerdelay=0 + saucershot=150 + + NewLevel() + End Method + + Method NewLevel() + TAsteroid.minspeed=minspeed + TAsteroid.maxspeed=maxspeed + For Local f:Int=0 Until numast + astlist.AddLast(TAsteroid.Create()) + Next + freq=30 + hit=0 + bullets.Clear() + shotdelay=0 + hyperdelay=0 + End Method + + Method CheckShipLaunch() + Local x1:Int=GraphicsWidth()/2-100 + Local y1:Int=GraphicsHeight()/2-100 + Local x2:Int=GraphicsWidth()/2+100 + Local y2:Int=GraphicsHeight()/2+100 + + If waitdelay=0 Or KeyHit(GameConfig.khyper) + FlushKeys() + waiting=False + EndIf + + waitdelay:-1 + + For Local a:TAsteroid=EachIn astlist + If saucer Or (a.x>x1 And a.xy1 And a.y0 + ac[f]:-1 + Else + a[f]:+1 + EndIf + al:+0.1 + Next + + SetRotation(0) + SetScale(1,1) + GameGFX.font.Centre("paused",GraphicsHeight()/2-16) + + Flip + Wend + + SetAlpha(1) + SetRotation(0) + SetScale(1,1) + + FlushKeys + Sounds.EndPause() + End Method + + Method Play:Int() + Cls + + If waiting And lives>=0 + CheckShipLaunch() + EndIf + + If astlist.Count()=0 + If leveldelay=0 + leveldelay=200 + Else + leveldelay:-1 + If leveldelay=0 + numast=Min(20,numast+2) + minspeed=Min(0.5,minspeed+0.05) + maxspeed=Min(2.0,maxspeed+0.05) + saucertime=Max(10,saucertime-20) + saucershot=Max(25,saucershot-10) + NewLevel() + EndIf + EndIf + EndIf + + If lives>-1 And saucer=Null + saucerdelay:+1 + + If saucerdelay>saucertime + saucerdelay=0 + If score<10000 + saucer=TSaucer.Create(True,saucershot) + ElseIf score<20000 + saucer=TSaucer.Create(Rand(0,1),saucershot) + Else + saucer=TSaucer.Create(False,saucershot) + EndIf + EndIf + EndIf + + + If lives>-1 And Not waiting + If KeyDown(GameConfig.kleft) + ship.ang:-20 + If ship.ang<0 + ship.ang:+3600 + EndIf + EndIf + + If KeyDown(GameConfig.kright) + ship.ang=(ship.ang+20) Mod 3600 + EndIf + + If KeyDown(GameConfig.kthrust) + Sounds.PlayerThrust(True) + dx=Min(2,Max(-2,dx+Lookup.si[ship.ang]*0.1)) + dy=Min(2,Max(-2,dy+Lookup.co[ship.ang]*0.1)) + Else + Sounds.PlayerThrust(False) + EndIf + + If KeyDown(GameConfig.khyper) And hyperdelay=0 + x=Rand(10,GraphicsWidth()-10) + y=Rand(10,GraphicsHeight()-10) + dx=0 + dy=0 + hyperdelay=100 + EndIf + + If KeyDown(GameConfig.kfire) And shotdelay=0 + Sounds.PlayerFire() + bullets.AddLast(TShot.Create(ship)) + shotdelay=25 + EndIf + + If shotdelay>0 + shotdelay:-1 + EndIf + + If hyperdelay>0 + hyperdelay:-1 + EndIf + + If KeyHit(KEY_ESCAPE) + lives=-1 + TParticleMachine.AsteroidExplosion(ship.x,ship.y) + Sounds.ShipExplosion() + EndIf + + x:+dx + y:+dy + + If x<0 + x:+GraphicsWidth() + EndIf + + If x>=GraphicsWidth() + x:-GraphicsWidth() + EndIf + + If y<0 + y:+GraphicsHeight() + EndIf + + If y>=GraphicsHeight() + y:-GraphicsHeight() + EndIf + + ship.x=x + ship.y=y + EndIf + + SetAlpha(0.7) + + For Local a:TAsteroid=EachIn astlist + a.Update() + Next + + For Local f:Int=1 To lives + lifeship.x=f*9 + lifeship.Draw() + Next + + SetAlpha(1) + + GameGFX.font.Centre(score,0) + SetColor(255,255,255) + If lives<0 + For Local s:TShot=EachIn bullets + s.Update(bullets,astlist,saucer) + Next + Else + For Local s:TShot=EachIn bullets + Local sc:Int=s.Update(bullets,astlist,saucer) + score:+sc + + If sc + If score>extralife + If extralife=10000 + extralife=50000 + Else + extralife:+50000 + EndIf + lives:+1 + Sounds.ExtraLife() + EndIf + + hit:+1 + If hit>3 + hit=0 + If freq>15 + freq:-1 + EndIf + EndIf + EndIf + Next + EndIf + + Local hit:Int=False + + If saucer + SetAlpha(0.7) + If lives>-1 And Not waiting + hit=saucer.Update(ship) + Else + saucer.Update(Null) + EndIf + + SetAlpha(1) + + If saucer.Finished() + saucer=Null + Sounds.NoSaucer() + EndIf + EndIf + + If lives<0 + deaddelay:-1 + GameGFX.font.Centre("game over",292) + Else + If Not waiting + SetAlpha(0.7) + + If hit Or Collides(ship.DrawToPointList()) + TParticleMachine.ShipExplosion(ship.x,ship.y) + Sounds.ShipExplosion() + + lives:-1 + x=GraphicsWidth()/2 + y=GraphicsHeight()/2 + dx=0 + dy=0 + ship.ang=0 + ship.x=x + ship.y=y + waiting=True + waitdelay=500 + FlushKeys() + EndIf + + SetAlpha(1) + EndIf + EndIf + + TParticleMachine.Process() + Sounds.Update(freq) + + Flip + + If KeyHit(GameConfig.kpause) + Pause() + EndIf + + Return deaddelay>0 + End Method + + Method Collides:Int(list:TList) + For Local a:TAsteroid=EachIn astlist + For Local p:TVectorGfxPoint=EachIn list + If a.obj.IsInside(p.x,p.y) + Return True + EndIf + Next + Next + + Return False + End Method + +End Type -- cgit v1.2.3