vrld/HardonCollider — Issue #5: Problems with non central rotating
Author: dannyfritz
Created: 2011-11-01 03:23:51+00:00
State: open

It just simply doesn't work with rectangles that aren't rotating around their center.
```Lua
require 'HC'

function love.load()
HC.init(100, on_collision)
rect = HC.addRectangle(200,200,200,50)
rect.tag = "rect"
mouse = HC.addRectangle(0,0,32,32)
mouse.tag = "mouse"
end

function love.update(dt)
function love.keypressed(key)
if (key == "left") then
rotate = dt
end
if (key == "right") then
rotate = -dt
end
if (key == "kpenter") then
rotate = 0
end
end
rect:rotate(rotate or 0, 150, 150)

mouse:moveTo(love.mouse.getPosition())
debugUPDATE()
HC.update(dt)
--end testing
end

function on_collision(dt, shape_a, shape_b)
text[#text+1] = string.format("Colliding")
local shape_other
if shape_a.tag == "mouse" then
shape_other = shape_b
elseif shape_b.tag == "mouse" then
shape_other = shape_a
end
if shape_other.tag == "enemy" then
text[#text+1] = string.format("Enemy "..shape_other.id.."!")
elseif shape_other.tag == "rect" then
text[#text+1] = string.format("Rect!"..dt)
end
end

function love.draw()
rect:draw('line')
mouse:draw('fill')
debugDRAW()
end

text = {}
function debugUPDATE()
while #text > 40 do
table.remove(text, 1)
end
end
function debugDRAW()
for i = 1,#text do
love.graphics.print(text[#text - (i-1)], 10, i * 15)
end
end
```