summaryrefslogtreecommitdiff
path: root/gametypes.bmx
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2006-04-21 21:07:17 +0000
committerIan C <ianc@noddybox.co.uk>2006-04-21 21:07:17 +0000
commit0c54a57c59fdce1ffc0055f57983ad090a3e18e6 (patch)
treeae80ddf184d5f0133ce09c1fb2bc520b7b5b8524 /gametypes.bmx
parent6de8d28ffb5da5c4ac7260b467dd5afc85286fde (diff)
Updates while working away
Diffstat (limited to 'gametypes.bmx')
-rw-r--r--gametypes.bmx109
1 files changed, 96 insertions, 13 deletions
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