Skip to content

Repository files navigation

HC - General Purpose 2D Collision Detection System with LÖVE

Documentation and examples here: http://hc.readthedocs.org/

HC=require'HC'-- array to hold collision messageslocaltext= {}
functionlove.load()
-- add a rectangle to the scenerect=HC.rectangle(200,400,400,20)
-- add a circle to the scenemouse=HC.circle(400,300,20)
mouse:moveTo(love.mouse.getPosition())
endfunctionlove.update(dt)
-- move circle to mouse positionmouse:moveTo(love.mouse.getPosition())
-- rotate rectanglerect:rotate(dt)
-- check for collisionsforshape, deltainpairs(HC.collisions(mouse)) dotext[#text+1] =string.format("Colliding. Separating vector = (%s,%s)",
delta.x, delta.y)
endwhile#text>40dotable.remove(text, 1)
endendfunctionlove.draw()
-- print messagesfori=1,#textdolove.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 screenlove.graphics.setColor(255,255,255)
rect:draw('fill')
mouse:draw('fill')
end

About

General purpose collision detection library for the use with LÖVE.

Resources

Stars

482 stars

Watchers

21 watching

Forks

Releases

Packages

Used by

Contributors

Languages