Tjakka5

Untitled

Aug 26th, 2018
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. function love.run()
  2.     if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
  3.  
  4.     if love.timer then love.timer.step() end
  5.  
  6.     local dt = 0
  7.  
  8.     return function()
  9.         if love.event then
  10.             love.event.pump()
  11.             for name, a,b,c,d,e,f in love.event.poll() do
  12.                 if name == "quit" then
  13.                     if not love.quit or not love.quit() then
  14.                         return a or 0
  15.                     end
  16.                 end
  17.                 love.handlers[name](a,b,c,d,e,f)
  18.             end
  19.         end
  20.  
  21.         if love.timer then dt = love.timer.step() end
  22.  
  23.       local Physics = Physics
  24.       local Physics_Entities = Physics.entities
  25.       local Position_Entities = Position.entities
  26.       local Velocity_Entities = Velocity.entities
  27.  
  28.       for i = 0, Physics.count - 1 do
  29.          local maxX, maxY = maxX, maxY
  30.  
  31.          local id = Physics_Entities[i]
  32.  
  33.          local position = Position_Entities._data[id]
  34.          local velocity = Velocity_Entities._data[id]
  35.  
  36.          position.x = position.x + velocity.x * dt
  37.          position.y = position.y + velocity.y * dt
  38.  
  39.          if position.x > maxX or
  40.             position.y > maxY then
  41.  
  42.             position.x = 0
  43.             position.y = 0
  44.          end
  45.       end
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment