Skip to content

Commit

Permalink
Spider now walks randomly around
Browse files Browse the repository at this point in the history
  • Loading branch information
robashton committed Apr 1, 2012
1 parent d48b1ec commit 01227b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion site/assets.json

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions site/game.js
Expand Up @@ -940,7 +940,8 @@
Quad.call(this, 80, 80);
this.x = 700;
this.y = 625;
this.destx = 0;
this.destx = 40;
this.speedx = 1.0;
this.id = "spider";
this.panicking = false;
this.panickedAnimation = new PanickedSpiderAnimation(this);
Expand Down Expand Up @@ -977,9 +978,18 @@
this.currentStrategy();
},
happyStrategy: function() {

var difference = this.destx - (this.x + this.width / 2.0);
if(Math.abs(difference) < 10)
return this.chooseNewDirection();
if(difference < 0)
this.x -= this.speedx;
else
this.x += this.speedx;
this.determineIfWaterIsHigh();
},
chooseNewDirection: function() {
this.destx = (Math.random() * 700) + 50;
},
panickedStrategy: function() {
// Do bugger all
},
Expand Down

0 comments on commit 01227b3

Please sign in to comment.