diff --git a/README.md b/README.md index 07ed6d1..a14cc31 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,50 @@ -# This repository is no longer maintained - -If you do maintain an active fork, please open a PR to add it to this readme. - -All other issues reports and pull requests will not be attended. - -## General Purpose 2D Collision Detection System +## HC - General Purpose 2D Collision Detection System with [LÖVE](https://love2d.org) Documentation and examples here: http://hc.readthedocs.org/ + +```lua +HC = require 'HC' + +-- 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 circle to the scene + mouse = HC.circle(400,300,20) + 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 +```