-
-
Save jywarren/1872096b5257e6317f7e to your computer and use it in GitHub Desktop.
eating green, from https://github.com/jywarren/antfarm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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