Page 1 of 1

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

Posted: Sat Dec 28, 2013 8:37 pm
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 

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

Posted: Sat Dec 28, 2013 11:59 pm
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

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

Posted: Sun Dec 29, 2013 9:12 am
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.)

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

Posted: Sun Dec 29, 2013 11:30 am
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.

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

Posted: Sun Jan 05, 2014 9:58 am
by italomaia
Things are working for me now. Thanks!

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

Posted: Sun Jan 05, 2014 1:49 pm
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.

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

Posted: Tue Jan 07, 2014 6:16 pm
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.