function love.mousepressed(x, y, button)
if button == "l" then
mx = love.mouse.getX()
my = love.mouse.getY()
drawx = mx
drawy = my
end
end
function love.draw()
love.graphics.rectangle("fill",drawx,drawy,40,40)
end
It says that there is a bad argument in the rectangle.
I triple checked to see the errors but I cant see anything wrong!
Help?
Are drawx and drawy defined before the mouse is clicked the first time.
I'd also like to point out that mx and my aren't needed, the return values could be stored in drawx and drawy directly, and that you don't need to call getX and getY, because an x and y are already passed to it (and more exact too, due to the timing).
function love.mousepressed(x, y, button)
if button == "l" then
drawx = x
drawy = y
end
end
function love.draw()
if drawx~=nil and drawy~=nil then
love.graphics.rectangle("fill",drawx,drawy,40,40)
end
end
This way it wont render the rectangle until you've given a value to drawx and drawy, unless you've declared them in love.load() .
Also use tab to indent code, makes it much neater