浏览代码

Merge branch 'development' of github.com:snaky-particles/snaky-particles into models

Conflicts:
	js/controller.js
Dima Mironov 10 年之前
父节点
当前提交
df395b6321
共有 4 个文件被更改,包括 6 次插入6 次删除
  1. 2 2
      js/controller.js
  2. 1 1
      js/models/snake.js
  3. 2 2
      js/script.js
  4. 1 1
      js/views/physicist.js

+ 2 - 2
js/controller.js

@@ -18,6 +18,7 @@ var Controller = function(){
 		{collectible: higgs, probability: 3e-3},
 		{collectible: electron, probability: .05}
 		]
+	this.stage = new createjs.Stage("demoCanvas");
 }
 
 Controller.prototype.update_views = function(){
@@ -38,7 +39,6 @@ this.prototype.spawn_collectibles = function(){
 Controller.prototype.start_game = function(){
 	// this.session = new Session();
     var c = this;
-	this.stage = new createjs.Stage("demoCanvas");
 	createjs.Ticker.on("tick", function(e){c.tick(e);});
 	createjs.Ticker.setFPS(20);
 	this.bind_events();
@@ -99,7 +99,7 @@ Controller.prototype.tick = function(event){
 
 Controller.prototype.get_next_cell_position = function(){
 	var ph0 = this.snake.physicists[0];
-	var next_cell = ph0.position;
+	var next_cell = Object.create(ph0.position);
 	next_cell.x += ph0.direction.x;
 	next_cell.y += ph0.direction.y;
 	if (next_cell.x < 0) next_cell.x = this.grid_size.x - 1;

+ 1 - 1
js/models/snake.js

@@ -1,7 +1,7 @@
 var Snake = function(n_physicisits){
 	this.physicists = [];
 	for (var i = 0; i < n_physicisits; i++){
-		this.physicists.push(new Physicist(this, {x: 5 - i, y: 0}));
+		this.physicists.push(new Physicist(this, {x: 0, y: 0}));
 	}
     this.physicists[0].direction = {x: 0, y: 0};
 	this.new_physicists = [];

+ 2 - 2
js/script.js

@@ -3,9 +3,9 @@ var stage, controller;
 function init() {
     controller = new Controller;
 
-    controller.start_game();
-
     resize();
+
+    controller.start_game();
 }
 
 function resize() {

+ 1 - 1
js/views/physicist.js

@@ -1,6 +1,6 @@
 (function(window) {
     function PhysicistView(modelObject){
-        this.graphics.beginFill("red").drawCircle(0, 0, 20);
+        this.graphics.beginFill("red").drawCircle(0, 0, window.cell_size * 0.9 / 2);
         this.model = modelObject;
     }