function load()
local f = love.graphics.newFont(love.default_font, 12)
love.graphics.setFont(f)
mouseClickText = "Mouse Clicked at: 0, 0"
mouseX = 0
mouseY = 0
end
function update(dt)
if love.mouse.isDown(love.mouse_left) then
x = love.mouse.getX()
y = love.mouse.getY()
if love.mouse.getY() < 576 then -- only needed for screens not evenly divisible by 32
mouseX = math.floor(x / 32)
mouseY = math.floor(y / 32)
mouseClickText = "Mouse Clicked at: ".. mouseX .. " (" .. x .. ")" ..", ".. mouseY .. " (" .. y .. ")"
end
end
end
function draw()
love.graphics.draw(mouseClickText, 5, 15)
love.graphics.rectangle(1, mouseX * 32, mouseY * 32, 32, 32)
end
Click and drag and the square aligns itself to an invisible grid. Part of a project I have in mind.
We don't borrow, we don't read, we don't rent, we don't lease, we take the minds!