Polygon Collision?

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
danlthemanl
Prole
Posts: 11
Joined: Fri Jun 04, 2010 1:11 am

Polygon Collision?

Post by danlthemanl »

I'm implementing a collision system into my Level editor, I have rectangle collision all done, but I can't figure out how polygon collision could possibly work. Is this built into Love2d? Is there an module or api that does this for me? or is it easy to implement that I just haven't thought of?

help!
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Polygon Collision?

Post by tentus »

Kurosuke needs beta testers
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Polygon Collision?

Post by Kadoba »

It sounds like HardonCollider would be best suited for you. It's very easy to set up and use.
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Polygon Collision?

Post by Ensayia »

To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know. Anything more complex will require you to code it yourself.

A few seasoned users have done some simple libraries. Search for Fizz and HardonCollider on the wiki. Fizz isn't polygonal, but may contain code you can build from so long as you remember to credit Taehl. I know nothing of HC.

Love is a framework rather than an engine, something you can build these sort of features into through your own modules and/or libraries.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Polygon Collision?

Post by BlackBulletIV »

Ensayia wrote:To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know. Anything more complex will require you to code it yourself.
For shapes, love.physics (which is a wrapper around Box2D) supports circles and 8-point, convex polygons (including a helper for rectangles). If you need something more complex than that, you would use multiple shapes in association with a body.

Whether you go for custom collision or the physics system depends on your needs. If you want some simple collision detection, custom is the way to go. If you want physics simulation, love.physics is most likely best.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Polygon Collision?

Post by vrld »

Ensayia wrote:To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know.
Not true. HardonCollider does support collision between points, circles and arbitrary simple (=non intersecting) polygons, including rectangles.

If you don't want to use the existing detection system, you can build your own using the shape:collidesWith() method. You can even go deeper and just use the Polygon class that provides useful things like triangulation and splitting into convex sub polygons.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Polygon Collision?

Post by nevon »

vrld wrote:
Ensayia wrote:To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know.
Not true. HardonCollider does support collision between points, circles and arbitrary simple (=non intersecting) polygons, including rectangles.
Wouldn't two colliding polygons per definition be intersecting? Or am I misunderstanding something here?
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Polygon Collision?

Post by Ensayia »

I meant no existing implementation built into LOVE itself. Sorry if I confused people.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Polygon Collision?

Post by Robin »

nevon wrote:Wouldn't two colliding polygons per definition be intersecting? Or am I misunderstanding something here?
I think he meant polygons intersecting themselves.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: mrmorr and 2 guests