That general idea should work, yes, although the code you posted is
really far from idiomatic Lua – the way you're creating and using global variables is really verbose.
Here's the same thing, rewritten to be a lot cleaner and more maintainable:
Code: Select all
local draw = true
function updatestatus(val)
draw = val
end
function love.load()
logo = love.graphics.newImage("military12.png")
end
function love.draw()
if draw then
love.graphics.print("Welcome to a game created by KOTwarrior", 400, 100)
love.graphics.draw(logo, 300, 200)
end
end
function love.mousepressed(x, y, button)
if button == "l" then
updatestatus(false)
end
end
function love.mousereleased(x, y, button)
if button == "l" then
updatestatus(true)
end
end
Or using [wiki]love.mouse.isDown[/wiki] instead of love.mousepressed and love.mousereleased:
Code: Select all
local draw = true
function love.load()
logo = love.graphics.newImage("military12.png")
end
function love.update(dt)
local mousedown = love.mouse.isDown("l")
draw = not mousedown
end
function love.draw()
if draw then
love.graphics.print("Welcome to a game created by KOTwarrior", 400, 100)
love.graphics.draw(logo, 300, 200)
end
end