<script src="http://spelprogrammering.nu/simple.js">
function Zombie(startX, startY, xSpeed)
{
this.x = startX;
this.y = startY;
this.xSpeed = xSpeed;
this.update = function()
{
this.x += this.xSpeed;
save();
translate(this.x, this.y);
rectangle(3, 30, 23, 65, "lightgreen");
rectangle(3, 15, 23, 65, "gray");
circle(15, 0, 20, "lightgreen");
circle(0, 0, 3, "red");
rectangle(-35, 20, 30, 14, "lightgreen");
rectangle(-20, 20, 30, 14, "gray");
restore();
};
}
function start()
{
zombies = [];
for (var i = 0; i < 100; i++)
{
zombies.push(new Zombie(totalWidth + random(200),
random(totalHeight),
-(1 + 2 * random(100) / 100)));
}
}
function update()
{
clearScreen();
for (var i = 0; i < zombies.length; i++)
{
zombies[i].update();
}
}
</script>
Gå tillbaka