Skip to content

Commit

Permalink
Better continuous animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Brede Skaug committed May 30, 2015
1 parent dff39e3 commit 69e76c7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions devbuild/js/canvasAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var canvas = document.getElementById('headCanvas'),
hdc = canvas.getContext('2d'),
canvasMeta = {},
helloInt = [],
gt = makeGlobalTimer(100);
gt = makeGlobalTimer(200);

function Init()
{
Expand All @@ -26,17 +26,23 @@ function registerSquareTrail(tileY){
this.x = result.x;

// Set max height here
if(this.x == 20) {
if((this.x - this.delay)-Random.getInt(0, 4) >= 0 && !this.spawnedNew) {
registerSquareTrail(this.y);
this.spawnedNew = true;
}

if(this.x == 20) {
if (!this.spawnedNew) registerSquareTrail(this.y);
gt.cancelCallback(this.id);
}

}.bind({
"id" : callbackID,
"y" : tileY,
"x" : 0,
"delay" : Random.getInt(0, 20),
"color" : Random.getColor([153,66,20])}
"id" : callbackID,
"spawnedNew" : false,
"y" : tileY,
"x" : 0,
"delay" : Random.getInt(0, 20),
"color" : Random.getColor([153,66,20])}
), callbackID);
}

Expand Down

0 comments on commit 69e76c7

Please sign in to comment.