joseleeph

Untitled

Apr 27th, 2021
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function love.load()
  2. Object = require "classic" -- classic is the library used to simulate classes
  3. require "player"
  4. require "enemy"
  5. require "bullet"
  6.  
  7. player = Player()
  8. enemy = Enemy()
  9. -- we need to shoot bullets, so a list of bullets is created
  10. listOfBullets = {}
  11. end
  12.  
  13. function love.keypressed(key)
  14. player:keyPressed(key)
  15. end
  16.  
  17. function love.update(dt)
  18. player:update(dt)
  19. enemy:update(dt)
  20. -- iterate through the table and update/draw all the bullets
  21. for i,v in ipairs(listOfBullets) do
  22. v:update(dt)
  23. end
  24. end
  25.  
  26. function love.draw()
  27. player:draw()
  28. enemy:draw()
  29. for i,v in ipairs(listOfBullets) do
  30. v:draw()
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment