vrld / HC

General purpose collision detection library for the use with LÖVE.
http://hc.readthedocs.org/
402 stars 48 forks source link

testPoint #7

Closed dannyfritz closed 12 years ago

dannyfritz commented 12 years ago

I added a testPoint function to HC.

-- Test point for collision with active objects
function HC:testPoint(x, y)
    -- collect colliding shapes
    local point = newPointShape(x,y);
    new_shape(self, point);

    local colliding = {};
    for _,shape in pairs(point:_getNeighbors()) do
        if shape:collidesWith(point) then
            table.insert(colliding, shape);
        end
    end

    self:remove(point);

    if #colliding == 0 then
        return false;
    end
    return colliding;
end
dannyfritz commented 12 years ago

Eh, I'll do the proper pull request.