Finish the game and show the score.

game.over(false, effects.confetti)

When you end the game, all game control stops and the player gets a message that the game is over (finished). The last action is frozen on the screen and both the current and highest scores are displayed. The game program will reset when you press a key or button.

You can also select an optional screen effect to display when the game ends.


  • win: an optional boolean value to say if the player has won the game. If set to true, a message is displayed telling the player that they won the game.
  • effect: an optional built-in effect to display when the game ends.


No lives? Game Over

Check every second to see if the player has any lives left. If not, end the game!

game.onUpdateInterval(1000, function () {
    if (info.life() < 1) {

Show Game Over effect

When the game score reaches 20, end the game and show the bubbles effect.

game.onUpdateInterval(100, function () {
game.onUpdate(function () {
    if (info.score() > 20) {
        game.over(false, effects.bubbles)

See also

start countdown