title: How can I work with class in lua love2d (OOP)
body: <p>I don't know how make classes in lua so I used code which was recommended on forum.
  But always only one object works. First one have coordinates x,y and the other object share his coordinates. Can you explain what I´m doing wrong in this code.
  Thank you for your advice.</p>
  
  <p>My code:</p>
  
  <pre><code>require("class") 
  
  asteroid = class:new()
  
  function asteroid:init(x,y)
          asteroid.b = love.physics.newBody(world, x ,y , "dynamic")
          asteroid.s = love.physics.newCircleShape(35)
          asteroid.f = love.physics.newFixture(asteroid.b, asteroid.s)  
  end
  
  function love.load() 
  world = love.physics.newWorld(0, 50, true)  
  
  asteroid1= asteroid:new(100,100)
  asteroid2= asteroid:new(700,100)
  end
  
  
  function love.update(dt)
   world:update(dt)
  end
  
  function love.draw()
  love.graphics.circle("line", asteroid1.b:getX(),asteroid1.b:getY(), asteroid1.s:getRadius(), 35)
  love.graphics.circle("line", asteroid2.b:getX(),asteroid2.b:getY(), asteroid2.s:getRadius(), 35)
  end
  </code></pre>
  
  <p>Recommended code:</p>
  
  <pre><code>__HAS_SECS_COMPATIBLE_CLASSES__ = true
  
  local class_mt = {}
  
  function class_mt:__index(key)
      return self.__baseclass[key]
  end
  
  class = setmetatable({ __baseclass = {} }, class_mt)
  
  function class:new(...)
      local c = {}
      c.__baseclass = self
      setmetatable(c, getmetatable(self))
      if c.init then
          c:init(...)
      end
      return c
  end
  </code></pre>