<script src="http://spelprogrammering.nu/simple.js">
function start()
{
turtle.direction = 75;
turtle.y = totalHeight;
turtle.x = 90;
turtle.color = mixColor(100,100,70);
shape = 'x';
rules = {'x': 'F+[[x]-x]-F[-Fx]+x',
'F': 'FF',
'+': '+',
'-': '-',
'[': '[',
']': ']'};
angle = 20;
events = {};
events['x'] = function() {};
events['F'] = function() { turtle.move(3); };
events['+'] = function() { turtle.turnLeft(angle) };
events['-'] = function() { turtle.turnRight(angle) };
events['['] = function() { turtle.pushPosition() };
events[']'] = function() { turtle.popPosition(); };
iterations = 7;
for (var i = 0; i < iterations; i++)
{
currentLength = shape.length;
newShape = '';
for (var u = 0; u < currentLength; u++)
newShape += rules[shape.charAt(u)];
shape = newShape;
}
for (var i = 0; i < shape.length; i++)
events[shape.charAt(i)]();
}
</script>
Gå tillbaka