Dima Mironov hace 10 años
padre
commit
668544a856
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      js/controller.js

+ 3 - 1
js/controller.js

@@ -148,9 +148,11 @@ Controller.prototype.tick = function(event){
 		this.snake.move(next_cell);
 		this.canTurn = true;
 		this.physicists_count();
-		while (var next_cell_content = this.is_position_occupied(next_cell)){
+		var next_cell_content  = this.is_position_occupied(next_cell);
+		while (next_cell_content){
 			if (next_cell_content && next_cell_content.collectible) this.snake.physicists[0].collect(next_cell_content.collectible);
 			if (next_cell_content && next_cell_content.physicist && event.time > 5000) this.game_over();
+			next_cell_content = this.is_position_occupied(next_cell);
 		}
         if(this.collectibles.length < this.maximum_spawns){
 		    this.spawn_collectibles();