Class structure using hardonCollider

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
reydefuego
Prole
Posts: 2
Joined: Sat Oct 25, 2014 6:27 am

Class structure using hardonCollider

Post by reydefuego »

I started on my first project with Love2d and lua, and for the collision detection I started by implementing it on my own but I decided to use hardoncollider instead. My question is right now I have three classes Sprite, Unit, Player: That's the hierarchy of the classes Sprite->Unit->Player and, judging by the tutorials, the collision object from hardoncollider has to be a base class? I was trying to do something like that, but I wasn't sure how to. I'm also using middleclass for the classes.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Class structure using hardonCollider

Post by bartbes »

Because (iirc) you don't have objects, you have shapes. So in this case your entity would have a shape, not be one.
caldur
Prole
Posts: 20
Joined: Tue Mar 13, 2012 3:30 pm

Re: Class structure using hardonCollider

Post by caldur »

bartbes wrote:Because (iirc) you don't have objects, you have shapes. So in this case your entity would have a shape, not be one.
yep, and the thing that gives me a little headache is that you will have to route the collision info back to the owner of the shape...
so it's either implementing AABB and collision method on custome obejcts OR mannually add a reference field to the shape after it has been added to the collider... I am wondering if there is any alternative way to handle this more elegantly?
reydefuego
Prole
Posts: 2
Joined: Sat Oct 25, 2014 6:27 am

Re: Class structure using hardonCollider

Post by reydefuego »

I figured it out now, thanks bartbes.
so it's either implementing AABB and collision method on custome obejcts OR mannually add a reference field to the shape after it has been added to the collider... I am wondering if there is any alternative way to handle this more elegantly?
What I did was check what object was iterating over a table to find what the player was colliding with in the collision callback. Not the most elegant solution, but it works.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 220 guests