|#port, on draw zombie , needs, @draw zombie , reads, @zombie index| |#port body, on draw zombie, lua| print("DRAWING ZOMBIE", zombie_index) local zombie = state.zombies[zombie_index] love.graphics.setColor(0.145, 0.133, 0.169) love.graphics.circle("fill", zombie.x + 5, zombie.y + 5, zombie.r) love.graphics.setColor(0.882, 0.314, 0.282) love.graphics.circle("fill", zombie.x, zombie.y, zombie.r) love.graphics.setColor(1, 1, 1) |#port, on zombie track player , needs, @zombie track player , reads, @zombie index| |#port body, on zombie track player, lua| local player = state.player local zombie = state.zombies[zombie_index] zombie.angle = math.atan2(player.y - zombie.y, player.x - zombie.x) |#port, on move zombie , needs, @move zombie , reads, @zombie index| |#port body, on move zombie, lua| local zombie = state.zombes[zombie_index] zombie.x = zombie.x + state.dt * math.cos(zombie.angle) * 310 zombie.y = zombie.y + state.dt * math.sin(zombie.angle) * 310 |#port, on check zombie hit player , needs, @check zombie hit player , reads, @zombie index| , @zombie hit player |#port body, on check zombie hit player, lua| local player = state.player local zombie = state.zombies[zombie_index] local min_distance = player.r + zombie.r local distance = math.sqrt((player.x - zombie.x) ^ 2 + (player.y - zombie.y) ^ 2) local hit = distance < min_distance counters["@zombie hit player"] = hit and 1 or 0 zombie.dead = hit |#port, on get zombie count, needs, @get zombie count| @zombie count |#port body, on get zombie count, lua| print("ZOMBIE COUNT") counters["@zombie count"] = #state.zombies |#port, on is zombie dead , needs, @is zombie dead , reads, @zombie index| @zombie is dead |#port body, on is zombie dead, lua| local zombie = state.zombies[zombie_index] counters["@zombie is dead"] = zombie.dead and 1 or 0 |_| Handling important counters |clear @zombie index| clearing @zombie index:9007199254740991 |clearing @zombie index, @zombie index| , clearing @zombie index |clearing @zombie index| |restoring @zombie index, temporary @zombie index| restoring @zombie index, @zombie index |restoring @zombie index| |restore @zombie index| , restoring @zombie index:9007199254740991 |clear @zombie count| clearing @zombie count:9007199254740991 |clearing @zombie count, @zombie count| , clearing @zombie count |clearing @zombie count| |restoring @zombie count, temporary @zombie count| restoring @zombie count, @zombie count |restoring @zombie count| |restore @zombie count| , restoring @zombie count:9007199254740991 |_| bounds check @zombie index |comparing @zombie index to @zombie count, @zombie index, @zombie count| , temporary @zombie index , temporary @zombie count , comparing @zombie index to @zombie count |comparing @zombie index to @zombie count, @zombie count| , temporary @zombie count , result @zombie index < @zombie count |comparing @zombie index to @zombie count, @zombie index| , temporary @zombie index , result @zombie index > @zombie count |comparing @zombie index to @zombie count| |get compare @zombie index to @zombie count result, result @zombie index < @zombie count| , @zombie index < @zombie count |get compare @zombie index to @zombie count result, result @zombie index > @zombie count| , @zombie index > @zombie count |get compare @zombie index to @zombie count result| , @zombie index = @zombie count |clearing excess results, result @zombie index < @zombie count| , clearing excess results |clearing excess results, result @zombie index = @zombie count| , clearing excess results |clearing excess results, result @zombie index > @zombie count| , clearing excess results |clearing excess results| |clear excess results| , clearing excess results:9007199254740991 |clean up compare @zombie index to @zombie count| , restore @zombie index , restore @zombie count , get compare @zombie index to @zombie count result , clear excess results |compare @zombie index to @zombie count| , comparing @zombie index to @zombie count:9007199254740991 , clean up compare @zombie index to @zombie count |_| The loop needed for drawing zombies |set up draw zombies loop| , @zombie index , @get zombie count , compare @zombie index to @zombie count |drawing zombie, @zombie index > @zombie count| |drawing zombie, @zombie index = @zombie count| , @draw zombie |drawing zombie, @zombie index < @zombie count| , @draw zombie , draw next zombie |draw next zombie| , @zombie index , drawing zombie , compare @zombie index to @zombie count |clean up draw zombies loop| , clear @zombie index , clear @zombie count |_| trigger for drawing zombies |draw zombies| , clear @zombie index , set up draw zombies loop , drawing zombie , clean up draw zombies loop