Problem dealing with changing a variable
Posted: Mon Jan 20, 2014 5:35 pm
Hello, I'm creating a menu and I have a difficulty button that is supposed to change from easy to medium, medium to hard and hard to easy when pressed. However nothing seems to happen, and I don't get an error either.
Here is the code related to the difficulty option.
I've attached the full code of the menu to this post.
Thanks
Here is the code related to the difficulty option.
Code: Select all
state = mainmenu
mode = "Easy"
function love.update()
if state == mainmenu then
if love.mouse.isDown("l") then
local x, y = love.mouse.getPosition()
if x >= 50 and x <= 175 and y >= 151 and y <= 175 and mode == "Easy" then -- Difficulty Easy Button Position
mode = "Medium"
end
if x >= 50 and x <= 175 and y >= 151 and y <= 175 and mode == "Medium" then -- Difficulty Medium Button Position
mode = "Hard"
end
if x >= 50 and x <= 175 and y >= 151 and y <= 175 and mode == "Hard" then -- Difficulty Hard Button Position
mode = "Easy"
end
end
end
end
function love.draw()
if state == mainmenu then
love.graphics.print("Difficulty:", 50, 150)
if mode == "Easy" then
love.graphics.print("Easy", 135, 150)
end
if mode == "Medium" then
love.graphics.print("Medium", 135, 150)
end
if mode == "Hard" then
love.graphics.print("Hard", 135, 150)
end
end
end
Thanks