<script src="http://spelprogrammering.nu/simple.js"> function start() { zombies = []; deadZombies = []; clock = 0; spawn = 30; bulletsFired = 0; zombiesKilled = 0; circle(10, 10, 10, "lightgreen"); zombieColor = getPixel(10, 10); fill("black"); zombies.push(new Zombie(2, 43)); zombies.push(new Zombie(1, 93)); zombies.push(new Zombie(2, 27)); zombies.push(new Zombie(4, 79)); zombies.push(new Zombie(2, 107)); zombies.push(new Zombie(5, 83)); zombies.push(new Zombie(4, 152)); zombies.push(new Zombie(5, 62)); zombies.push(new Zombie(3, 127)); zombies.push(new Zombie(1, 36)); //zombies.push(new Zombie(1, 34)); //zombies.push(new Zombie(4, 82)); //zombies.push(new Zombie(1, 66)); //zombies.push(new Zombie(3, 163)); //zombies.push(new Zombie(1, 161)); //zombies.push(new Zombie(1, 117)); zombies.push(new Zombie(4, 126)); zombies.push(new Zombie(5, 115)); zombies.push(new Zombie(1, 150)); zombies.push(new Zombie(4, 119)); for (var i = 0; i < 600; i++) fakeupdate(); } function fakeupdate() { if (! c.running) { return; }; mouse = { x: 655, y: 500 }; fill("white"); rectangle(0, 0, totalWidth, totalHeight/2, "37B6FF"); save(); translate(totalWidth / 2 - 370, totalHeight / 2 - 300); rectangle(200, 150, 300, 200, "A22416"); circle(510, 100, 40, "white"); circle(550, 100, 50, "white"); circle(600, 100, 30, "white"); circle(640, 120, 30, "white"); circle(620, 90, 30, "white"); circle(150, 100, 40, "white"); circle(200, 100, 40, "white"); circle(100, 100, 30, "white"); circle(250, 90, 30, "white"); triangle(200, 150, 350, 30, 500, 150, "A22416"); triangle(200, 150, 350, 30, 500, 150, "black"); triangle(210, 150, 350, 40, 490, 150, "A22416"); triangle(210, 150, 350, 40, 490, 150, "white"); triangle(215, 150, 350, 45, 485, 150, "A22416"); rectangle(200, 150, 10, 200, "white"); rectangle(490, 150, 10, 200, "white"); rectangle(250, 180, 50, 50, "C2E9FF"); rectangle(400, 180, 50, 50, "C2E9FF"); rectangle(325, 270, 50, 80, "996633"); rectangle(325, 270, 2, 80, "845E3A"); rectangle(330, 270, 2, 80, "845E3A"); rectangle(335, 270, 2, 80, "845E3A"); rectangle(340, 270, 2, 80, "845E3A"); rectangle(345, 270, 2, 80, "845E3A"); rectangle(350, 270, 2, 80, "845E3A"); rectangle(355, 270, 2, 80, "845E3A"); rectangle(360, 270, 2, 80, "845E3A"); rectangle(365, 270, 2, 80, "845E3A"); rectangle(370, 270, 2, 80, "845E3A"); rectangle(375, 270, 2, 80, "845E3A"); rectangle(423, 180, 3, 50, "black"); rectangle(400, 200, 50, 3, "black"); rectangle(274, 180, 3, 50, "black"); rectangle(250, 200, 50, 3, "black"); circle(335, 300, 3, "black"); rectangle(335, 299, 8, 2, "black"); circle(335, 300, 3, "black"); rectangle(600, 200, 40, 150, "280000"); circle(600, 200, 40, "339900"); circle(640, 200, 40, "339900"); circle(620, 150, 40, "339900"); circle(670, 200, 30, "339900"); circle(570, 200, 40, "339900"); circle(590, 160, 40, "339900"); circle(650, 160, 40, "339900"); circle(600, 200, 7, "red"); circle(640, 190, 8, "red"); circle(600, 150, 9, "red"); circle(680, 200, 7, "red"); circle(550, 200, 10, "red"); circle(650, 140, 7, "red"); restore(); rectangle(totalWidth / 2 + 32, totalHeight / 2 - 78, 13, 10, "#996600"); rectangle(totalWidth / 2 + 37, totalHeight / 2 - 83, 2, 7, "black"); circle(totalWidth / 2 + 38, totalHeight / 2 - 72, 3, "black"); for (var i = 0; i < deadZombies.length; i++) { var zombie = deadZombies[i]; zombie.update(); } for (var i = 0; i < zombies.length; i++) { var zombie = zombies[i]; if (zombie.dead && !zombie.pushed) { zombie.pushed = true; deadZombies.push(zombie); } else { zombie.update(); pixel = getPixel(mouse.x, mouse.y); if (mouse.left && pixel.red == zombieColor.red && pixel.green == zombieColor.green && pixel.blue == zombieColor.blue) { circle(mouse.x, mouse.y, 10, "red"); zombie.dead = true; zombie.x += 50 + random(50); zombie.deadAngle = random(360); zombiesKilled++; deadZombies.push(zombie); } if (zombie.x < (zombie.angle) % 150 + 120) { zombie.x += 50 + random(50); zombie.deadAngle = random(360); zombiesKilled++; zombie.dead = true; } if (zombie.x < 50) { blast(totalWidth / 2, totalHeight / 2, 100, 50, "yellow"); blast(totalWidth / 2, totalHeight / 2, 80, 30, "orange"); text(totalWidth / 2 - 200, totalHeight * 0.8, 30, "BASE SELF DESTRUCT", "black"); stopUpdate(); } } } circle(totalWidth / 2 + 38, totalHeight / 2 - 72, 4, "yellow"); line(totalWidth / 2 + 38, totalHeight / 2 - 70, mouse.x, mouse.y, 2, "yellow"); ring(mouse.x, mouse.y, 30, 3, "black"); line(mouse.x - 30, mouse.y, mouse.x - 5, mouse.y, 1, "black"); line(mouse.x + 30, mouse.y, mouse.x + 5, mouse.y, 1, "black"); line(mouse.x, mouse.y - 30, mouse.x, mouse.y - 5, 1, "black"); line(mouse.x, mouse.y + 30, mouse.x, mouse.y + 5, 1, "black"); blast(mouse.x, mouse.y, 20, 10, "yellow"); bulletsFired = 47; clock++; } function blast(x, y, radius, fragments, color) { save(); translate(x, y); circle(0, 0, radius/10, color); for (var i = 0; i < fragments; i++) { rotate(radius + fragments * i % 360); circle((i * fragments + radius) % radius, 0, (radius + fragments + 2 * i) % radius/5, color); } restore(); } function Zombie(speed, angle, dead) { this.x = distance(0, 0, totalWidth / 2, totalHeight / 2) + 100; this.y = 0; this.speed = speed; this.angle = angle; this.dead = dead; this.update = function() { save(); translate(totalWidth / 2, totalHeight / 2); rotate(this.angle); translate(this.x, this.y); if (this.dead) { this.skinColor = "orange"; rotate(this.deadAngle); } else { this.x -= this.speed; this.skinColor = "lightgreen"; if (this.angle > 90 && this.angle < 270) { scale(1, -1) }; } scale(0.5, 0.5); if (this.dead) { save(); for (var i = 0; i < 10; i++) { rotate(this.deadAngle % (i * 20)); circle(3 * i, 0, 3 * i, "red"); } restore(); } rectangle(3, 30, 23, 65, this.skinColor); rectangle(3, 15, 23, 65, "gray"); circle(15, 0, 20, this.skinColor); circle(0, 0, 3, "red"); rectangle(-35, 20, 30, 14, this.skinColor); rectangle(-20, 20, 30, 14, "gray"); restore(); }; } </script>