Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make some squirrels, yo

  • Loading branch information...
commit 69eee98f582df7da7ee703855f23d30d088e4745 1 parent fe17154
@cpdean authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 zeds.js
View
13 zeds.js
@@ -83,6 +83,10 @@ var Zeds = function() {
return this.next_action = this.death;
}
+ if (this.hunger > 200) {
+ return this.next_action = this.reproduce;
+ }
+
// CAN YOU EAT???
var food = z.mushrooms();
var touching_food = _.filter(food, function(f) {
@@ -177,6 +181,15 @@ var Zeds = function() {
};
};
+ this.reproduce = function() {
+ this.hunger = 50;
+ var x = Math.random() * z.canvas.width;
+ var y = Math.random() * z.canvas.height;
+ var s = new Squirrel(x, y);
+ z.agents.push(s);
+ return this;
+ };
+
};
Squirrel.prototype = new Agent();
Please sign in to comment.
Something went wrong with that request. Please try again.