Page 1 of 1

Help with Classic library

Posted: Thu Jul 18, 2024 11:16 am
by bigfry74
Hello, hoping someone can advise me what I'm doing wrong. I am using Classic from RXI as a library to use an object oriented structure to my project. I am clearly not understanding something fundamental. I have created two boxes but only one is being drawn....is there no way to draw all the boxes with one command as i am attempting here.

Re: Help with Classic library

Posted: Thu Jul 18, 2024 1:20 pm
by pgimeno
Hello, welcome to the forums.

First, if you check the docs: https://github.com/rxi/classic you'll see that the syntax for creating an object is not to call the new() method: you should call the class instead. In your case:

Code: Select all

  player = Player()
  box1 = Terrain(500, 550, 100, 50)
  floor = Terrain(0, 575, 800, 25)
Second, you should be calling the update() and draw() method of each object, not of the class:

Code: Select all

function love.update(dt)
  player:update(dt)
  box1:update(dt)
  floor:update(dt)
end

function love.draw()
  player:draw()
  box1:draw()
  floor:draw()
end
That will probably suffice, haven't tested it. Anyway there are a few more minor additional problems.