Advertisement
Guest User

Untitled

a guest
Aug 7th, 2024
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. love.graphics.setDefaultFilter('nearest', 'nearest')
  2.  
  3. require('libs/collision')
  4.  
  5. local sceneManager = require('sceneManager/sceneManager'):new()
  6.  
  7. function love.load()
  8.     sceneManager:load()
  9. end
  10.  
  11. function love.update(dt)
  12.     sceneManager:update(dt)
  13. end
  14.  
  15. function love.draw()
  16.     sceneManager:draw()
  17. end
  18.  
  19. local game = require('game/game')
  20.  
  21. local playScene = {}
  22.  
  23. function playScene:new()
  24.     local obj = {
  25.         game = game:new()
  26.     }
  27.     setmetatable(obj, self)
  28.     self.__index = self
  29.     return obj
  30. end
  31.  
  32. function playScene:load()
  33.     self.game:load()
  34. end
  35.  
  36. function playScene:update(dt)
  37.     self.game:update(dt)
  38. end
  39.  
  40. function playScene:draw()
  41.     self.game:draw()
  42. end
  43.  
  44. return playScene
  45.  
  46. local map = require('map/map')
  47. local player = require('player.player')
  48. local gui = require('gui/gui')
  49. local camera = require('libs/camera')
  50. local critter = require('entities/critter')
  51.  
  52. local game = {}
  53.  
  54. function game:new()
  55.     local obj = {}
  56.     setmetatable(obj, self)
  57.     self.__index = self
  58.     return obj
  59. end
  60.  
  61. function game:load()
  62.     self.map = map:new()
  63.     self.map:load()
  64.     addCurrentMap(self.map.currentMap)
  65.    
  66.     self.player = player:new()
  67.     self.player:load()
  68.     self.gui = gui:new(self.player)
  69.     self.gui:load()
  70.  
  71.     self.critter = critter:new()
  72.     self.critter:load()
  73.  
  74.     self.camera = camera:new(0, 0, nil, nil, 1)
  75.     self.camera:load()
  76.     self.camera:setTarget(self.player)
  77.  
  78.     print("Game loaded", self)
  79.     print("Map loaded: ", self.map)
  80.     print("Player loaded: ", self.player)
  81.     print("GUI loaded: ", self.gui)
  82.     print("Camera loaded: ", self.camera)
  83. end
  84.  
  85. function game:update(dt)
  86.     self.map:update(dt)
  87.     self.player:update(dt)
  88.     self.critter:update(dt)
  89.     self.camera:update(dt)
  90.     self.gui:update(dt)
  91. end
  92.  
  93. function game:draw()
  94.     self.camera:apply()
  95.     self.map:draw()
  96.     self.player:draw()
  97.     self.critter:draw()
  98.     self.gui:draw()
  99.     self.camera:unset()
  100. end
  101.  
  102. return game
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement