u/Soft-Notice-2696

▲ 6 r/love2d

Currently struggling to make a clickable button function. anyone got anything?

_G.love = require 'love'

function love.load()
creature = {}
creature.rep = 0
love.mouse.setCursor(mousepng)
cursor2 = love.graphics.newImage('cursor2.png')
love.mouse.setVisible(false)
end

function love.update(dt)

end

function love.draw()
x, y = love.mouse.getPosition()
love.graphics.print(creature.rep, 10, 10)
love.graphics.draw(cursor2, x, y)
love.graphics.rectangle('line', 300, 400, 100, 100)
love.graphics.print(x)
love.graphics.print(y, 30)
end

function love.mousepressed(x, y, button)
if button == 1 then
if x < 300 and x > 400 and y < 500 and y > 400 then
creature.rep = creature.rep +1
end
end
end

ignore the 'creature' thing. its going to be a horror game. when i click withing the boundries set the number dosent change at all. very confused.

reddit.com
u/Soft-Notice-2696 — 6 days ago