startTime = Clock.ElapsedMilliseconds
If mode = "falling" Then
dirX = 0
dirY = 0
If up = 1 And fuel>0 then
UpPressed()
dirX = 0 * thrust
dirY = -1 * thrust
Stack.PushValue("p",dirX)
Stack.PushValue("p",dirY)
Stack.PushValue("p",angle)
RotVecRet()
dirX = Stack.PopValue("p")
dirY = Stack.PopValue("p")
EndIf
If left = 1 then
LeftPressed()
EndIf
If right = 1 then
RightPressed()
EndIf
velocityX = velocityX + dirX
velocityY = velocityY + dirY
velocityY = velocityY + gravity
Print()
shipPosX = shipPosX + velocityX
shipPosY = shipPosY + velocityY
If Up = 1 And fuel>0 And thrust>0 Then
If Math.Remainder(counter,2)=1 then
Shapes.ShowShape(shipThrust)
Shapes.Rotate(shipThrust,angle)
Shapes.Move(shipThrust,shipPosX,shipPosY)
Shapes.HideShape(shipThrust2)
else
Shapes.ShowShape(shipThrust2)
Shapes.Rotate(shipThrust2,angle)
Shapes.Move(shipThrust2,shipPosX,shipPosY)
Shapes.HideShape(shipThrust)
EndIf
Shapes.HideShape(ship)
Else
Shapes.ShowShape(ship)
Shapes.Rotate(ship,angle)
Shapes.Move(ship,shipPosX,shipPosY)
Shapes.HideShape(shipThrust)
Shapes.HideShape(shipThrust2)
EndIf
EndIf
'GraphicsWindow.BrushColor = "Red"
'Shapes.Move(dot,shipPosX,shipPosY)
tooFast = "false"
CheckLandingSpeed()
If shipPosY > 520 And mode = "falling" Then
If tooFast = "false" And shipPosX>padX And shipPosX<(padX+80) And (angle<10 Or angle>350) Then
angle = 0
Shapes.Rotate(shipThrust,angle)
mode = "landed"
Landed()
NewLevel()
fuel = maxFuel
Shapes.Move(pad,padX,padY)
Else
Die()
EndIf
ElseIf shipPosY < -60 And mode <> "dead" Then
Die()
ElseIf shipPosX < -64 Then
shipPosX = GraphicsWindow.Width-1
ElseIf shipPosX > GraphicsWindow.Width Then
shipPosX = -63
EndIf
If mode = "dead" Then
opacity = opacity - 3
If opacity<0 Then
opacity = 0
GraphicsWindow.ShowMessage("Game over, you scored "+score,"Crash landing!")
score = 0
SetMaxFuel()
Initialise()
EndIf
Shapes.SetOpacity(explode,opacity)
EndIf
Sub Die
Shapes.HideShape(ship)
Shapes.HideShape(shipThrust)
Shapes.HideShape(shipThrust2)
Shapes.Move(explode,shipPosX,shipPosY)
Shapes.ShowShape(explode)
opacity = 100
mode = "dead"
level = 0
EndSub
Sub Landed
mode = "landed"
level = level + 1
score = score + fuel + level*10
GraphicsWindow.ShowMessage("Aced, you scored "+score,"Eagle has landed!")
Initialise()
EndSub
'******************************************************************************************
'******************************************************************************************
' alter the code below here only
'******************************************************************************************
'******************************************************************************************
'the player pressed the UP Arrow button
Sub UpPressed
thrust = 0.2
EndSub
Sub CheckLandingSpeed
If speed > 30 Then
tooFast = "true"
EndIf
EndSub
'set the starting fuel level
Sub SetMaxFuel
maxFuel = 200
EndSub
'the player pressed the LEFT Arrow button
Sub LeftPressed
angle = angle - 1
EndSub
'the player pressed the RIGHT Arrow button
Sub RightPressed
angle = angle + 1
EndSub
'called when the player lands and a new level begins
Sub NewLevel
padX = Math.GetRandomNumber(550)
If maxFuel > 50 Then
maxFuel = maxFuel - 10
EndIf
EndSub
'set the colour of the fuel text
Sub FuelLeft
fuelColour = "Green"
If fuel < 20 Then
fuelColour = "Red"
EndIf
EndSub
'set the colour of the speed text
Sub CurrentSpeed
speedColour = "Green"
If tooFast = "true" Then
SpeedColour = "Red"
EndIf