Skip to content

Instantly share code, notes, and snippets.

@jywarren
Forked from anonymous/ant.js
Last active September 29, 2015 23:50
Show Gist options
  • Save jywarren/1872096b5257e6317f7e to your computer and use it in GitHub Desktop.
Save jywarren/1872096b5257e6317f7e to your computer and use it in GitHub Desktop.
onRun = function() {
ant.direction += Math.random()*10-5;
if (ant.green() > 0) {
ant.foodPlace = [ant.x, ant.y];
ant.energy += ant.green();
ant.green(0);
}
if (ant.energy <= 0) ant.die();
ant.color = "rgba(" + ant.energy + ", 50, 0, 1)";
ant.energy -= 2;
ant.trail('green', 255); // color, amount
}
onBump = function() {
ant.direction += 90;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment