Help with Classic library

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
bigfry74
Prole
Posts: 1
Joined: Sat Jul 06, 2024 11:30 pm

Help with Classic library

Post 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.
Attachments
Screenshot 2024-07-18 121221.png
Screenshot 2024-07-18 121221.png (33.65 KiB) Viewed 1979 times
Screenshot 2024-07-18 121227.png
Screenshot 2024-07-18 121227.png (57.35 KiB) Viewed 1979 times
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help with Classic library

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 8 guests