Uploaded by Abdulhakim Aytbay

Zombie tutorial

advertisement
How to make a zombie game :)
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
}
function drawSurvivor (survivor) {
line(0, 0, survivor.x, survivor.y);
}
function drawZombie(zombie) {
circle(zombie.x, zombie.y, 30);
}
function moveZombie(zombie) {
return p5.Vector.fromAngle(zombie.heading(), zombie.mag() — 1);
}
function drawZombies(zombies) {
zombies.forEach(zombie => drawZombie(zombie));
}
movedZombies = []
for (const zombie of gameZombies) {
movedZombies.push(moveZombie(zombie));
}
gameZombies = movedZombies;
Download