Advertisement
Guest User

Untitled

a guest
Feb 14th, 2024
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. function move_zombies()
  2. local occupied = {}
  3. for z in all(zombies) do
  4. last_x = z.x
  5. last_y = z.y
  6. if x > z.x then z.x += z.speed end
  7. if x < z.x then z.x -= z.speed end
  8. if collide(z.x,z.y,0) then z.x = last_x end
  9. if y > z.y then z.y += z.speed end
  10. if y < z.y then z.y -= z.speed end
  11. if collide(z.x,z.y,0) then z.y = last_y end
  12. if hit(z.x,z.y,8,8,x,y,8,8) then
  13. stop('dead')
  14. end
  15. for o in all(occupied) do
  16. if hit(z.x,z.y,8,8,o.x,o.y,8,8) then
  17. z.x = last_x
  18. z.y = last_y
  19. break
  20. end
  21. end
  22. add (occupied,{x=z.x,y=z.y})
  23. end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement