Skip to content
This repository
Browse code

[*] Game over notice was added.

  • Loading branch information...
commit 3ba7406cfbcdb6b6ceb5a78d7107de14c4bb7234 1 parent 6105c4b
Andrew Kulakov authored

Showing 2 changed files with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. +18 0 js/controller.js
  2. +1 0  js/player.js
18 js/controller.js
@@ -58,6 +58,24 @@ TextGalactic.Controller = atom.Class(
58 58 }));
59 59 },
60 60
  61 + gameOver: function () {
  62 + var ctx = this.ctx;
  63 +
  64 + ctx.fillStyle = "#fff";
  65 + ctx.font = "normal normal " + (TextGalactic.Settings.font_size + 15) + "px courier";
  66 + ctx.fillText(
  67 + "Game over",
  68 + Math.round(this.activeScene.resources.rectangle.to.x / 2) - 110,
  69 + Math.round(this.activeScene.resources.rectangle.to.y / 2)
  70 + );
  71 + ctx.font = "normal normal " + (TextGalactic.Settings.font_size) + "px courier";
  72 + ctx.fillText(
  73 + "You score: " + this.score,
  74 + Math.round(this.activeScene.resources.rectangle.to.x / 2) - 100,
  75 + Math.round(this.activeScene.resources.rectangle.to.y / 2) + (TextGalactic.Settings.font_size + 15)
  76 + );
  77 + },
  78 +
61 79 drawScore: function () {
62 80 var ctx = this.ctx;
63 81 ctx.fillStyle = "#000";
1  js/player.js
@@ -42,6 +42,7 @@ TextGalactic.Player = atom.Class(
42 42
43 43 if (this.health < 0) {
44 44 this.destroy();
  45 + this.options.controller.gameOver();
45 46 }
46 47
47 48 return this;

0 comments on commit 3ba7406

Please sign in to comment.
Something went wrong with that request. Please try again.