game.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. local Game = class()
  2. Game.tag = 'client'
  3. function Game:load(options)
  4. self.options = options
  5. self.event = app.util.event()
  6. self.net = app.net.client()
  7. self.input = app.util.input()
  8. self.view = app.media.view()
  9. self.collision = app.logic.collision()
  10. self.players = app.player.controller()
  11. self.spells = app.logic.spells()
  12. self.buffs = app.logic.buffs()
  13. self.particles = app.media.particles()
  14. self.effects = app.media.effects()
  15. self.sound = app.media.sound()
  16. self.map = app.logic.map()
  17. self.hud = app.ui.hud.controller()
  18. self.event:on('game.quit', function(data)
  19. app.util.context:remove(ctx)
  20. app.util.context:add(app.context.menu)
  21. end)
  22. end
  23. function Game:update()
  24. self.net:update()
  25. self.buffs:update()
  26. self.players:update()
  27. self.spells:update()
  28. self.particles:update()
  29. self.effects:update()
  30. self.map:update()
  31. self.view:update()
  32. self.sound:update()
  33. self.hud:update()
  34. end
  35. function Game:draw()
  36. self.view:draw()
  37. end
  38. function Game:quit()
  39. self.net:quit()
  40. end
  41. function Game:mousepressed(...) self.hud:mousepressed(...) end
  42. function Game:mousereleased(...) self.hud:mousereleased(...) end
  43. function Game:keypressed(key) self.hud:keypressed(key) end
  44. function Game:keyreleased(key) self.hud:keyreleased(key) end
  45. function Game:textinput(character) self.hud:textinput(character) end
  46. function Game:resize()
  47. self.view:resize()
  48. self.hud:resize()
  49. self.effects:resize()
  50. end
  51. return Game