diff options
author | Ian C <ianc@noddybox.co.uk> | 2006-04-21 21:07:17 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2006-04-21 21:07:17 +0000 |
commit | 0c54a57c59fdce1ffc0055f57983ad090a3e18e6 (patch) | |
tree | ae80ddf184d5f0133ce09c1fb2bc520b7b5b8524 | |
parent | 6de8d28ffb5da5c4ac7260b467dd5afc85286fde (diff) |
Updates while working away
-rw-r--r-- | GFX/flame.png | bin | 172 -> 192 bytes | |||
-rw-r--r-- | GFX/sprites.bms | bin | 2911 -> 4231 bytes | |||
-rw-r--r-- | GFX/star.png | bin | 0 -> 158 bytes | |||
-rw-r--r-- | gametypes.bmx | 109 | ||||
-rw-r--r-- | global.bmx | 38 | ||||
-rw-r--r-- | missile_lock.bmx | 48 | ||||
-rw-r--r-- | particle.bmx | 10 |
7 files changed, 146 insertions, 59 deletions
diff --git a/GFX/flame.png b/GFX/flame.png Binary files differindex 1e5a662..5c0a425 100644 --- a/GFX/flame.png +++ b/GFX/flame.png diff --git a/GFX/sprites.bms b/GFX/sprites.bms Binary files differindex a16c28f..3673e52 100644 --- a/GFX/sprites.bms +++ b/GFX/sprites.bms diff --git a/GFX/star.png b/GFX/star.png Binary files differnew file mode 100644 index 0000000..4e3ee77 --- /dev/null +++ b/GFX/star.png diff --git a/gametypes.bmx b/gametypes.bmx index afd9997..4b0875a 100644 --- a/gametypes.bmx +++ b/gametypes.bmx @@ -21,6 +21,7 @@ ' $Id$ ' Strict +Import noddybox.algorithm Import "global.bmx" Type GameState @@ -28,30 +29,48 @@ Type GameState Global x:Double=0 Global y:Double=0 Global ang:Int=0 - Global shields:Int=0 + Global lives:Int=0 Function Reset() score=0 - x=0 - y=0 + x=400 + y=300 ang=0 - shields=3 + lives=3 + End Function + + Function Control() + If KeyDown(GameConfig.kleft) + ang:-2 + If ang<0 Then ang:+360 + End If + If KeyDown(GameConfig.kright) + ang=(ang+2) Mod 360 + End If + End Function + + Function Move() + x=(x+Lookup.si[ang]*2) Mod 800 + y=(y-Lookup.co[ang]*2) Mod 600 + If x<0 Then x:+800 + If y<0 Then y:+600 + Trail.Add() End Function Function Display() - Local s:String="SHIELDS " + Local s:String="LIVES " - For Local f:Int=1 To shields + For Local f:Int=1 To lives s:+"~~" Next - GFX.font.Draw("SCORE",-400,-300) - GFX.font.Draw(Number.Format(score),-400,-284,255,255,0) + GFX.font.Draw("SCORE",0,-0) + GFX.font.Draw(Number.Format(score),0,16,255,255,0) - GFX.font.Draw(s,-80,-300) + GFX.font.Centre(s,0) - GFX.font.DrawRight("HISCORE",399,-300) - GFX.font.DrawRight(Number.Format(GameConfig.hiscore),399,-284,255,255,0) + GFX.font.DrawRight("HISCORE",799,0) + GFX.font.DrawRight(Number.Format(GameConfig.hiscore),799,16,255,255,0) End Function End Type @@ -64,8 +83,8 @@ Type BackdropStar Field b:Int Method New() - x=Rand(-400,400) - y=Rand(-400,400) + x=Rand(0,800) + y=Rand(0,600) r=Rand(128,255) g=Rand(128,255) b=Rand(128,255) @@ -83,4 +102,68 @@ Type Backdrop s[f]=New BackdropStar Next End Function + + Function Draw() + For Local f:Int=0 To 399 + SetColor(s[f].r,s[f].g,s[f].b) + DrawImage(GFX.star,s[f].x,s[f].y) + Next + End Function +End Type + +Type TrailPart + Field x:Double + Field y:Double + Field ang:Double + Field al:Double + Field sc:Double + + Method New() + x=GameState.x + y=GameState.y + ang=GameState.ang + al=1 + sc=1 + End Method +End Type + +Type Trail + Global plist:TList + + Function Init() + plist=CreateList() + End Function + + Function Clear() + plist.Clear() + End Function + + Function Add() + plist.AddLast(New TrailPart) + End Function + + Function Draw() + SetColor(255,255,255) + Local l:TEasyLink=TEasyLink.Create(plist) + + While l.Value() + Local t:TrailPart=TrailPart(l.Value()) + + If t.al>0.1 + SetRotation(t.ang) + SetScale(t.sc,t.sc) + SetAlpha(t.al) + DrawImage(GFX.flame,t.x,t.y) + t.al:-0.05 + 't.sc:+0.1 + l.MoveNext() + Else + l.Remove() + EndIf + Wend + + SetRotation(0) + SetAlpha(1) + SetScale(1,1) + End Function End Type @@ -36,6 +36,7 @@ Incbin "GFX/ship.png" Incbin "GFX/missile.png" Incbin "GFX/exhaust.png" Incbin "GFX/flame.png" +Incbin "GFX/star.png" Const HERTZ:Int=70 @@ -44,12 +45,12 @@ Type Lookup Global co:Double[] Function Init() - si=New Double[3600] - co=New Double[3600] + si=New Double[360] + co=New Double[360] - For Local a:Double=0 To 3599 - si[a]=Sin(a/10.0) - co[a]=Cos(a/10.0) + For Local a:Double=0 To 359 + si[a]=Sin(a) + co[a]=Cos(a) Next End Function End Type @@ -64,6 +65,7 @@ Type GFX Global missile:TImage Global exhaust:TImage Global flame:TImage + Global star:TImage Function SafeLoadImage:TImage(p:String, mode:Int) Local i:TImage=LoadImage(p,mode) @@ -84,15 +86,18 @@ Type GFX title=SafeLoadImage("incbin::GFX/title.png",0) - ship=SafeLoadImage("incbin::GFX/ship.png",0) - flame=SafeLoadImage("incbin::GFX/flame.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",0) + 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) End Function End Type @@ -184,21 +189,24 @@ Type Scroller Function Init() msg=" " - msg=" " - msg:+"TAKE THE LAST REMAINING STAR-FIGHTER AND USE SKILL AND JUDGEMENT TO AVOID THE DEADLY MISSILES THE EVIL ALIENS ARE FIRING AT YOU WHILE " - msg:+"DESTROYING THEIR ADVANCING FLEET... " - msg:+"SHOW HEART YOUNG PILOT, THE EARTH IS DEPENDING UPON YOU!" + msg:+"DURING A TEST-FLIGHT OF THE STAR-FIGHTER OX-9 YOU ARE AMBUSHED IN THE ASTEROID FIELD... " + msg:+"THE EVIL EMPIRE CANNOT BE ALLOWED TO DESTROY THE PROTOTYPE SO YOU MUST PILOT THE WEAPONLESS OX-9 " + msg:+"AVOIDING THE DEADLY MISSILES UNTIL HELP ARRIVES... " + msg:+"SHOW HEART YOUNG PILOT, STAR-FLEET IS DEPENDING UPON YOU!" + 'msg:+"TAKE THE LAST REMAINING STAR-FIGHTER AND USE SKILL AND JUDGEMENT TO AVOID THE DEADLY MISSILES THE EVIL ALIENS ARE FIRING AT YOU WHILE " + 'msg:+"DESTROYING THEIR ADVANCING FLEET... " + 'msg:+"SHOW HEART YOUNG PILOT, THE EARTH IS DEPENDING UPON YOU!" - msgx=-400 + msgx=0 msgp=0 - msgy=560-300 + msgy=560 End Function Function Draw() GFX.font.Draw(msg[..70],msgx,msgy) msgx:-2 - If msgx<-(GFX.font.TextWidth(msg[0..1])+400) + If msgx<-GFX.font.TextWidth(msg[0..1]) msgx:+GFX.font.TextWidth(msg[0..1]) msg=msg[1..]+msg[0..1] EndIf diff --git a/missile_lock.bmx b/missile_lock.bmx index 21ba804..f4a4652 100644 --- a/missile_lock.bmx +++ b/missile_lock.bmx @@ -52,7 +52,6 @@ EndIf ? Graphics 800,600,32,HERTZ -SetOrigin(400,300) HideMouse SetBlend(ALPHABLEND) @@ -69,8 +68,8 @@ Lookup.Init() GameConfig.Load() Scroller.Init() Particles.Init() - -GameState.Reset() +Backdrop.Init() +Trail.Init() Global quit:Int=False @@ -84,10 +83,23 @@ Menu() While Not quit GameState.Reset() - TFadeScreen.DoFadeOut() + 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() - 'last_score=game.score + + TFadeScreen.DoFadeOut() Menu() Wend @@ -121,28 +133,26 @@ Function Menu() Local defkey:Int=0 Particles.Clear() + GameState.Reset() While Not done Cls If Rand(100)>30 - Particles.AddScaledImage(GFX.exhaust,Rand(-400,400),Rand(-400,400),0.3) + Particles.AddScaledImage(GFX.exhaust,Rand(0,800),Rand(0,600),0.3) End If - GameState.ang=(GameState.ang+2) Mod 3600 - - SetOrigin(400,300) + Backdrop.Draw() Particles.Draw() GameState.Display() Scroller.Draw() - SetOrigin(0,0) SetColor(255,255,255) DrawImage(GFX.title,0,0) If defkey>0 - If defkey=5 + If defkey=4 GFX.font.Centre("PRESS A KEY TO GO BACK TO THE MENU",380) Else GFX.font.Centre("DEFINE KEYS",350) @@ -152,16 +162,13 @@ Function Menu() 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("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.kfire),500,240,c3,c3,0) - GFX.font.Draw(KeySym(GameConfig.kpause),500,260,c4,c4,0) + GFX.font.Draw(KeySym(GameConfig.kpause),500,240,c3,c3,0) Local k:Int=-1 @@ -183,14 +190,12 @@ Function Menu() Case 2 GameConfig.kright=k Case 3 - GameConfig.kfire=k - Case 4 GameConfig.kpause=k End Select defkey:+1 - If defkey=6 + If defkey=5 GameConfig.Save() defkey=0 FlushKeys() @@ -213,7 +218,7 @@ Function Menu() GFX.font.Centre("COPYRIGHT (C) NODDYBOX 2006",200) - GFX.font.Centre("PRESS FIRE TO PLAY",300) + 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) @@ -227,12 +232,11 @@ Function Menu() EndIf EndIf - Flip + Flip(1) Wend Particles.Clear() TFadeScreen.DoFadeOut() - SetOrigin(400,300) End Function diff --git a/particle.bmx b/particle.bmx index 79c7f8c..4098598 100644 --- a/particle.bmx +++ b/particle.bmx @@ -68,12 +68,9 @@ Type TParticle End Function Method Update:Int() - Local p:TAlgoPointD=DoRotateD(x,y,3599-GameState.ang) - p.x:-GameState.x - p.y:+GameState.y SetAlpha(a) SetScale(s,s) - DrawImage(i,p.x,p.y) + DrawImage(i,x,y) x:+dx y:+dy life:-1 @@ -107,10 +104,6 @@ Type Particles End Function Function Draw() - Local r:Double=GetRotation() - - SetRotation(-GameState.ang/10.0) - SetColor(255,255,255) Local l:TEasyLink=TEasyLink.Create(plist) @@ -125,6 +118,5 @@ Type Particles Wend SetAlpha(1) SetScale(1,1) - SetRotation(r) End Function End Type |