A little Help!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Subedara
Prole
Posts: 1
Joined: Sun Feb 09, 2025 12:20 pm

A little Help!

Post by Subedara »

Hi Guys!

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
User avatar
dusoft
Party member
Posts: 793
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: A little Help!

Post by dusoft »

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], oscaradalid and 5 guests