summaryrefslogtreecommitdiff
path: root/game.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'game.bmx')
-rw-r--r--game.bmx102
1 files changed, 77 insertions, 25 deletions
diff --git a/game.bmx b/game.bmx
index ff6ddfa..fb0ada3 100644
--- a/game.bmx
+++ b/game.bmx
@@ -19,6 +19,7 @@ Type TGame
Const LEVEL_CANCELLED:Int= 4
Field level:TLevel
+ Field ship:TShip
Field mass:TList
Field point:TList
Field timer:Int
@@ -42,13 +43,14 @@ Type TGame
o.level=level
o.mass=CreateList()
o.point=CreateList()
- o.level.CreatePlayfield(o.mass,o.point)
+ o.ship=o.level.CreatePlayfield(o.mass,o.point)
+ o.mass.AddLast(o.ship)
o.timer=o.level.timer
o.num=o.point.Count()
o.done=LEVEL_NOTOVER
o.frame=0
o.placed=0
- o.txtoff=[GameGFX.font.TextWidth("PARTICLES"),GameGFX.font.TextWidth("CAPTURED"),GameGFX.font.TextWidth("TIMER"),GameGFX.font.TextWidth("LEFT")]
+ o.txtoff=[GameGFX.font.TextWidth("PARTICLES"),GameGFX.font.TextWidth("CAPTURED"),GameGFX.font.TextWidth("TIMER"),GameGFX.font.TextWidth("WAVES")]
o.playing=False
o.col=0
o.coli=5
@@ -126,26 +128,31 @@ Type TGame
GameGFX.font.CentreColoured("Need "+level.winpercent+"% to clear",y,col/2,col,col)
y:+yi
- Local n:Int=Int(level.placemass)
+ Local n:Int=Int(level.shipmass)
+ Local w:Int=Int(level.wavemass)
If level.invmass
n=-n
+ w=-w
EndIf
- If level.maxmass>1
- GameGFX.font.CentreColoured("You can place "+level.maxmass+" masses of " + n + " Newtons",y,col/2,col,col)
- Else
- GameGFX.font.CentreColoured("You can place 1 mass of " + n + " Newtons",y,col/2,col,col)
+ GameGFX.font.CentreColoured("Your ship has a mass of " + n + " Newtons",y,col/2,col,col)
+ y:+yi
+
+ If level.maxwave>1
+ GameGFX.font.CentreColoured("You can fire "+level.maxwave+" Gravity Waves of " + w + " Newtons",y,col/2,col,col)
+ ElseIf level.maxwave=1
+ GameGFX.font.CentreColoured("You can fire 1 Gravity Wave of " + w + " Newtons",y,col/2,col,col)
EndIf
y:+yi
- If level.placefriend
- GameGFX.font.CentreColoured("PLACED MASSES ARE COLLECTORS!",y,col,col/2,col/2)
+ If level.wrap
+ GameGFX.font.CentreColoured("THE UNIVERSE IS WARPED!",y,col,col/2,col/2)
y:+yi
EndIf
y:+yi
- GameGFX.font.Centre("Press Left Mouse Button",y)
+ GameGFX.font.Centre("Press Space",y)
y:+yi
SetScale(1,1)
@@ -155,8 +162,44 @@ Type TGame
captured=0
lost=0
- If playing
+ If playing
+ If done=LEVEL_NOTOVER
+ If KeyDown(GameConfig.kleft)
+ ship.RotateLeft()
+ EndIf
+
+ If KeyDown(GameConfig.kright)
+ ship.RotateRight()
+ EndIf
+
+ If KeyDown(GameConfig.kthrust)
+ ship.Thrust()
+ EndIf
+
+ If KeyDown(GameConfig.kreverse)
+ ship.Reverse()
+ EndIf
+
+ If KeyHit(GameConfig.kblast) And placed<level.maxwave
+ If level.invmass
+ ship.mass=-level.wavemass
+ Else
+ ship.mass=level.wavemass
+ EndIf
+ TParticleMachine.AddShockwave(ship)
+ placed:+1
+ Else
+ If level.invmass
+ ship.mass=-level.shipmass
+ Else
+ ship.mass=level.shipmass
+ EndIf
+ EndIf
+ EndIf
+
For Local m:TMass=EachIn mass
+ ship.Attract(m)
+
For Local s:TPoint=EachIn point
s.Attract(m)
Next
@@ -167,7 +210,7 @@ Type TGame
If playing
For Local m:TMass=EachIn mass
- m.Move()
+ m.Move(True)'(level.wrap)
m.Draw()
Next
Else
@@ -178,7 +221,7 @@ Type TGame
If playing
For Local s:TPoint=EachIn point
- s.Move()
+ s.Move(level.wrap)
s.Draw()
If s.dead
@@ -243,14 +286,12 @@ Type TGame
GameGFX.font.DrawColoured(percent+"%",txtoff[1]+210,0,50,255,50)
EndIf
- GameGFX.font.Draw("LEFT",400,0)
+ GameGFX.font.Draw("WAVES",400,0)
- SetScale(2,2)
SetColor(255,255,255)
- For Local f:Int=0 Until level.maxmass-placed
- DrawImage(GameGFX.mass,410+txtoff[3]+f*10,3)
+ For Local f:Int=0 Until level.maxwave-placed
+ DrawImage(GameGFX.shock,410+txtoff[3]+f*10,3)
Next
- SetScale(1,1)
GameGFX.font.Draw("TIMER",600,0)
@@ -263,28 +304,36 @@ Type TGame
Select done
Case LEVEL_NOTOVER
If playing
+ Rem
If placed<level.maxmass And mass.Count()<MAX_GRAV
- If MouseHit(1)
+ If KeyHit(KEY_SPACE)
Local m:TMass=New TMass
m.friend=level.placefriend
m.inverse=level.invmass
m.x=MouseX()
m.y=MouseY()
- m.img=GameGFX.mass
+ If m.friend
+ m.img=GameGFX.collector
+ Else
+ m.img=GameGFX.star
+ EndIf
m.mass=level.placemass
mass.AddLast(m)
placed:+1
EndIf
EndIf
+ EndRem
Else
Intro()
- If MouseHit(1)
+ If KeyHit(KEY_SPACE)
playing=True
+ FlushKeys()
EndIf
EndIf
If KeyHit(KEY_ESCAPE)
done=LEVEL_CANCELLED
+ FlushKeys()
EndIf
Case LEVEL_WON
If final_percent=100
@@ -294,6 +343,7 @@ Type TGame
If col=255 Or col=0
TParticleMachine.AddFirework(Rand(0,GraphicsWidth()),Rand(0,GraphicsHeight()))
+ 'TParticleMachine.AddShockwave(Rand(0,GraphicsWidth()),Rand(0,GraphicsHeight()))
coli=-coli
EndIf
EndIf
@@ -302,23 +352,25 @@ Type TGame
SetAlpha(0.7)
GameGFX.font.CentreColoured("LEVEL COMPLETED!",GraphicsHeight()/2+20,255,255,0)
GameGFX.font.CentreColoured("You got the pass mark with "+pass_time+" left on the clock",GraphicsHeight()/2+40,255,255,0)
- GameGFX.font.Centre("Press the Left Mouse Button",GraphicsHeight()/2+80)
+ GameGFX.font.Centre("Press Space",GraphicsHeight()/2+80)
SetScale(1,1)
SetAlpha(1)
- If MouseHit(1)
+ If KeyHit(KEY_SPACE)
done=LEVEL_FINISHED
+ FlushKeys()
EndIf
Case LEVEL_LOST
SetScale(2,2)
SetAlpha(0.7)
GameGFX.font.CentreColoured("LEVEL FAILED!",GraphicsHeight()/2+20,255,64,64)
- GameGFX.font.Centre("Press the Left Mouse Button",GraphicsHeight()/2+60)
+ GameGFX.font.Centre("Press Space",GraphicsHeight()/2+60)
SetScale(1,1)
SetAlpha(1)
- If MouseHit(1)
+ If KeyHit(KEY_SPACE)
done=LEVEL_FINISHED
+ FlushKeys()
EndIf
EndSelect