Last active
October 1, 2015 18:07
-
-
Save jywarren/130619c76cc6fd56bf1f to your computer and use it in GitHub Desktop.
This file contains 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
// set basic attributes here; | |
// "this" means this ant you're editing now | |
ant.speed = 1; | |
ant.color = 'red'; | |
ant.height = 40; | |
ant.width = 40; | |
// runs every frame: | |
onRun = function () { | |
ant.direction += Math.random()*10-5; // vary direction slightly, randomly, in degrees | |
ant.trail('blue', 100); // leave a trail of <color>, <amount> | |
// every 30 frames: | |
if (field.time % 30 == 0) { | |
// make a new ant | |
var child = field.populate(AntFarm.Ant, 1)[0]; | |
child.x = ant.x; | |
child.y = ant.y; | |
child.color = "blue"; | |
child.speed = 3; | |
child.queen = ant; | |
} | |
} | |
onBump = function () { | |
// change direction by 90 degrees: | |
ant.direction += 90; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment