rzvxa will maintain thes - update README

This commit is contained in:
Matthias Richter 2023-08-26 10:18:03 +02:00
parent ddb833158e
commit 814061b9a3

View File

@ -1,9 +1,50 @@
# This repository is no longer maintained ## HC - General Purpose 2D Collision Detection System with [LÖVE](https://love2d.org)
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
Documentation and examples here: http://hc.readthedocs.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
```