Skip to content

Commit

Permalink
removed smooth animation code, not even close to working
Browse files Browse the repository at this point in the history
  • Loading branch information
deificx committed Jan 3, 2016
1 parent 7fea248 commit 16aa906
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions src/snake.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,50 +169,19 @@ Snake.prototype.update = function(dt) {

Snake.prototype.render = function() {
var i;
var d;
var offsetX;
var offsetY;
var flip = -1;

if (this.state === IDLE) {
return;
}

this.c.fillStyle = '#333';

// vertical offset === 1 / this.grid.h * this.height * this.wait / this.cooldown;
for (i = 0; i < this.snake.length; i++) {
offsetX = 0;
offsetY = 0;
if (this.state === IDLE) {
if (i === 0) {
d = this.direction;
} else if (this.snake[i-1].y < this.snake[i].y) {
d = UP;
} else if (this.snake[i-1].x > this.snake[i].x) {
d = RIGHT;
} else if (this.snake[i-1].y > this.snake[i].y) {
d = DOWN;
} else {
d = LEFT;
}
switch (d) {
case UP:
offsetY = 1 / this.grid.h * this.height * this.wait / this.cooldown;
break;
case RIGHT:
offsetX = 1 / this.grid.w * this.width * this.wait / this.cooldown * flip;
break;
case DOWN:
offsetY = 1 / this.grid.h * this.height * this.wait / this.cooldown * flip;
break;
default:
offsetX = 1 / this.grid.w * this.width * this.wait / this.cooldown;
}
}
this.c.beginPath();
this.c.arc(
this.snake[i].x / this.grid.w * this.width + offsetX,
this.snake[i].y / this.grid.h * this.height + offsetY,
this.snake[i].x / this.grid.w * this.width,
this.snake[i].y / this.grid.h * this.height,
this.radius,
0,
Math.PI * 2);
Expand Down

0 comments on commit 16aa906

Please sign in to comment.