Closed MeleeGamer closed 8 months ago
You need to have all of the lua files, And you should require init.lua file.
Lua require has a feature that lets you require init.lua files with only giving the directory path, You can think of it as that index.js/ts does in the world of nodejs.
So download the whole project and put it in a directory for example thirdparty/HC
, then you can start using it like this:
-- See how the require path is the same as the directory containing lua files in this project.
HC = require('thirdparty.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
Okay, thanks!
Happy to hear that helped, Let me know if you need any further help with it.
Which files should I download in order to use this?