Ad
Log in to vote
1

Help me push a button with Love2D? (also uses Lua)

Asked by 2 years ago

Hello, I am using Love2D Lua, instead of Roblox Lua, i am sorry if this breaks the rules but I need help, it is supposed to add 1 to the score when I push a circle known as "Button" can somebody help?

function love.load()
  button = {}
  button.x = 200
  button.y = 200
  button.size = 50

  score = 0
  timer = 0

  myFont = love.graphics.newFont(40)
end

function love.update(dt)

end

function love.draw()
  love.graphics.setColor(1, 0, 0)
  love.graphics.circle("fill", button.x, button.y, button.size)

  love.graphics.setFont(myFont)
  love.graphics.setColor(1, 1, 1)
  love.graphics.print(score)
end

function love.mousepressed( x, y, button, istouch )
  if button == 1 then
    if distanceBetween(button.x, button.y, love.mouse.getX(), love.mouse.getY()) < button.size then
      score = score + 1

    end
  end
end

function distanceBetween(x1, y1, x2, y2)
  return math.sqrt((y2 - y1)^2 + (x2 - x1)^2)
end
0
https://love2d.org/forums/ and make sure delete the post before I moderate >:) Block_manvn 395 — 2y
0
this shouldn't be moderated, stop your power trip before i do Fifkee 2017 — 2y

Answer this question