Code: Select all
function love.load()
love.mouse.setVisible(false)
mouseImg = love.graphics.newImage("mouse.png")
moleImg = love.graphics.newImage("mole.png")
gameFont = love.graphics.newFont("karma future.ttf", 45)
score = 0
end
function love.update(dt)
end
function love.draw()
love.graphics.setFont(gameFont)
mole = love.graphics.draw(moleImg, 100 ,500)
x, y = love.mouse.getPosition()
love.graphics.draw(mouseImg, x, y)
love.graphics.print("Score: "..score)
end
function love.mousepressed(x, y, button, istouch)
size = mole.getWidth() * mole.getHeight()
distance = distanceBetween(x, y, mole.getX(), mole.getY())
if button == 1 then
if distance < a then
score = score + 1
end
end
end
function distanceBetween(x1, x2, y1, y2)
return math.sqrt((y2 - y1)^2 + (x2 - x1)^2)
end