Page 1 of 1

Merging Polygons using Hardon Collider

Posted: Thu Mar 03, 2016 11:36 am
by Kommandat
Hey everyone,

First here's some background. I'm working on making a video like Agar.io, except with polygons. You start off as a triangle and eating triangles smaller than you allows you to add new vertices (increasing your the area of the triangle you just ate). The player will always look like a triangulated polygon. Hopefully, the triangulated polygon will also look colorful and cool.

I'm running into one small issue with the code I've attached. Namely in,

Code: Select all

    for shape, delta in pairs(HC.collisions(player)) do
        text[#text+1] = string.format("Colliding. Separating vector = (%s,%s)",
                                      delta.x, delta.y)
        HC.remove(shape)
    end
I call HC.remove(shape) while checking for collisions with my player (because I want to eat the triangle I collided with). This seems to remove the shape from the physics engine but the shape is still drawn on the screen. How can I erase the shape from the screen/game entirely?

Also, I'm new to game development and Love2D and I'm not sure how I should approach the more challenging problem of merging shapes together. HC.polygon.mergedWith looks promising but HC.polygon does not support collisions. Is there anyway for me to use HC.polygon and still have collision detection?

Any advice regarding how I should organize my code would be much appreciated. Let me know if I need to clarify anything. Thank you so much for taking the time to look at my problem!