HardonCollider + 30log + Class-Common = rotate does not work

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
italomaia
Prole
Posts: 6
Joined: Fri Dec 25, 2009 3:46 pm

HardonCollider + 30log + Class-Common = rotate does not work

Post by italomaia »

Hello folks! :awesome:

I've been working real hard on my first simulator using love2d and now I got on my first badass problem.

This week, I decided to use a OO library to make my code easier to mantain and, as a option suggested in the love wiki, 30log was the way to go. After some coding here and there, after turning some good amount of code into classes for this library, Class-Common showed up in my browser. Seemed like a good idea so, I started using as well.

What happened then was pretty weird: my polygon that was just fine some time ago stopped working as it was. Right now it moves, as it was doing already, but no longer rotates. After some background lookup, I opened a ticket reporting the issue but, I do not want to refactor my code again. I want to keep using class-common, so (finally! :crazy: ), my question is: is there a OO library with common support that works alright with Hardon Collider?

This is the code for anyone willing to reproduce the "non rotation" problem.

Code: Select all

--uncomment to see rotation stop
--require '30logclasscommons'
shapes = require "hardoncollider.shapes"

pot = shapes.newPolygonShape(
  0, 10,
  10,  0,
  48,  0, 
  58, 10, 
  58, 30, 
  48, 40,
  10, 40,
  0, 30
)

local instance = pot

function love.load()
  instance:moveTo(100, 100)
end

function love.update(dt)
  instance:rotate(math.pi/4)
  instance:move(1, 0)
end

function love.draw()
  instance:draw()
end 
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: HardonCollider + 30log + Class-Common = rotate does not

Post by Roland_Yonaba »

Hi,

There was indeed a slight error in the previous implementation of 30logclasscommons, even though it passes all class-commons tests.
It was causing the class constructor common.class not to be able to override a given parent attribute with the given prototype attribute.
As such, in your case, ConvexPolygonShape.rotate was the exact same than Shape.rotate.
Well, that was not easy at all to spot. I might have fixed it, see the latest commit and let me know how it works.
If it's ok, I can tag it properly and release an official 0.6.1 version.

Regars,
Roland
Last edited by Roland_Yonaba on Sun Dec 29, 2013 11:27 am, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: HardonCollider + 30log + Class-Common = rotate does not

Post by bartbes »

Roland, could you create a test for that, so we can include it? (Feel free to add any more tests you can think of.)
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: HardonCollider + 30log + Class-Common = rotate does not

Post by Roland_Yonaba »

bartbes wrote:Roland, could you create a test for that, so we can include it? (Feel free to add any more tests you can think of.)
No problem, I will try to send a pull request as soon as possible.
I actually added a clause for that in 30log specification.
italomaia
Prole
Posts: 6
Joined: Fri Dec 25, 2009 3:46 pm

Re: HardonCollider + 30log + Class-Common = rotate does not

Post by italomaia »

Things are working for me now. Thanks!
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: HardonCollider + 30log + Class-Common = rotate does not

Post by Roland_Yonaba »

italomaia wrote:Things are working for me now. Thanks!
Awesome. Can you explain a bit more what you did to solve the problem ?
Thanks.
italomaia
Prole
Posts: 6
Joined: Fri Dec 25, 2009 3:46 pm

Re: HardonCollider + 30log + Class-Common = rotate does not

Post by italomaia »

Well, I was using classcommon in my project as a interface to 30log, so I did pretty much nothing. As soon as the 30log correction was applied, and I updated my 30log copy, things started to work.
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests