Just wanted to ask how do I add a collider in this type of game?
Code:
Code: Select all
function love.load()
player = {}
player.x = 200
player.y = 300
player.speedx = 5
player.speedy = 0
platform1 = {}
platform1.x = 200
platform1.y = 500
platform1.width = 200
platform1.height = 50
end
function love.update(dt)
player.y = player.y - player.speedy
if love.keyboard.isDown('right') then
player.x = player.x + player.speedx
end
if love.keyboard.isDown('left') then
player.x = player.x - player.speedx
end
player.speedy = player.speedy - 0.1
end
function love.draw()
love.graphics.circle('fill', player.x, player.y, 20)
love.graphics.rectangle('fill', platform1.x, platform1.y, platform1.width, platform1.height)
end