[SOLVED] Using HUMP class and HardonCollider crashes sometimes

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
User avatar
XHH
Citizen
Posts: 85
Joined: Thu Jun 20, 2013 6:43 pm
Location: US
Contact:

[SOLVED] Using HUMP class and HardonCollider crashes sometimes

Post by XHH »

I'm making a platformer that uses HardonCollider for collisions. Although it comes with a class library, I prefer using the HUMP class library. I tried using

Code: Select all

HC.polygon(198,330, 429,330, 429,297, 561,297, 561,198, 594,198, 594,363, 198,363)
to create a hitbox, but it froze up my program when I ran it. I tried running it again without using the HUMP class library and it worked fine.

This is a slightly altered line from the HC demo code:

Code: Select all

-- array to hold collision messages
local text = {}

function love.load()
    -- add a rectangle to the scene
    rect = HC.rectangle(200,400,400,20)

    -- add a polygon to the scene
    mouse = HC.polygon(198,330, 429,330, 429,297, 561,297, 561,198, 594,198, 594,363, 198,363)

    mouse:moveTo(love.mouse.getPosition())
end

function love.update(dt)
    -- move circle to mouse position
    mouse:moveTo(love.mouse.getPosition())

    -- rotate rectangle
    rect:rotate(dt)

    -- check for collisions
    for shape, delta in pairs(HC.collisions(mouse)) do
        text[#text+1] = string.format("Colliding. Separating vector = (%s,%s)",
                                      delta.x, delta.y)
    end

    while #text > 40 do
        table.remove(text, 1)
    end
end

function love.draw()
    -- print messages
    for i = 1,#text do
        love.graphics.setColor(255,255,255, 255 - (i-1) * 6)
        love.graphics.print(text[#text - (i-1)], 10, i * 15)
    end

    -- shapes can be drawn to the screen
    love.graphics.setColor(255,255,255)
    rect:draw('fill')
    mouse:draw('fill')
end
Is it possible to use the HUMP class library without having some kind of conflict with HardonCollider's built-in class? Also, this is the order in which I require them:

Code: Select all

Class = require "hump.class"
HC = require "HC"
Changing the order has not changed the result, though.

EDIT (SOLVED): After running it through zerobrane studio, turns out it crashed because I was overriding the table.remove function in another piece of code. >.<
I like to draw and program :)
Post Reply

Who is online

Users browsing this forum: No registered users and 41 guests