Saturday, 6 September 2014

Game Over

 Once the player had either been hit or left the screen the Game Over code will run. This code displays the words Game Over on the screen as shown below.



The game over code is as shown below

private action gameOver ()
This declares and sets the position of the game over text as well as calling the End Game
var GameOver :=  board → create text(100, 20, 40, "Game Over")
GameOver → set pos( board → width / 2 - 40,  board → height / 2 - GameOver → height)
 Gears → clear
 EndGame
end action

This code also invokes the EndGame code. this section of code takes the score and publishes it to the leader board as well as asking the player if they want to play again.

private action EndGame ()
This ensures that there is a 5 second wait before the score is posted and the game ends
time → run after(5, perform)
where perform() is
wall → clear
bazaar → post leaderboard score(math → round( game → score))
bazaar → post leaderboard to wall
time → sleep(3)
This sets the game to start again if the player wishes
if wall → ask boolean("Play Again?"""then
 main
else
time → stop
end if
end
end action

No comments:

Post a Comment