Pārlūkot izejas kodu

restart game after game over

eraisedtoipi 10 gadi atpakaļ
vecāks
revīzija
f028f86204
1 mainītis faili ar 16 papildinājumiem un 2 dzēšanām
  1. 16 2
      js/controller.js

+ 16 - 2
js/controller.js

@@ -273,6 +273,20 @@ Controller.prototype.physicists_count = function(){
 }
 
 Controller.prototype.game_over = function(){
-	alert("Game Over!");
-	// ...
+	alert("Game Over!\nScore: " + this.score);
+	this.snake = new Snake(this.initial_length);
+	this.canTurn = true;
+	this.counter = 0;
+	createjs.Ticker.reset();
+	createjs.Ticker.init();
+	for(var view in this.views){
+		this.stage.removeChild(this.views[view]);
+    }
+	for(var collectible in this.collectibles){
+		this.stage.removeChild(this.collectibles[collectible]);
+    }
+    this.collectibles = [];
+	this.views = [];
+	this.stage.clear();
+	this.start_game()// ...
 }