Now i fixed it already , i used the love.textinput(t) function for my input. I also used the string.upper() function to make all the letters uppercase when they get typed. In my code, i typed something like this:
Code: Select all
function puzzle1:init()
question = {}
question.font = love.graphics.getFont()
question.text = "Living thing, big, fat, gray"
question.w = question.font:getWidth(question.text)
question.h = question.font:getHeight(question.text)
question.x = love.graphics.getWidth() / 2 - question.w
question.y = 100
answerbox = {}
answerbox.image = love.graphics.newImage("images/answerbox.png")
answerbox.x = love.graphics.getWidth() / 2 - answerbox.image:getWidth() / 2
answerbox.y = love.graphics.getHeight() / 2
letter2 = ""
letter3 = ""
letter4 = ""
letter5 = ""
letter6 = ""
letter7 = ""
letter8 = ""
end
function puzzle1:update(dt)
end
function puzzle1:draw()
love.graphics.setColor(255, 255, 255)
love.graphics.draw(answerbox.image, answerbox.x, answerbox.y)
love.graphics.setColor(0, 0, 0)
love.graphics.print(question.text, question.x, question.y, 0, 2, 2)
love.graphics.print(hint1, 270, 340, 0, 2, 2)
love.graphics.print(letter2, 305, 340, 0, 2, 2)
love.graphics.print(letter3, 340, 340, 0, 2, 2)
love.graphics.print(letter4, 375, 340, 0, 2, 2)
love.graphics.print(letter5, 410, 340, 0, 2, 2)
love.graphics.print(letter6, 445, 340, 0, 2, 2)
love.graphics.print(letter7, 480, 340, 0, 2, 2)
love.graphics.print(letter8, 515, 340, 0, 2, 2)
end
function puzzle1:textinput(t)
if letter2 == "" then
letter2 = string.upper(t)
elseif letter3 == "" then
letter3 = string.upper(t)
elseif letter4 == "" then
letter4 = string.upper(t)
elseif letter5 == "" then
letter5 = string.upper(t)
elseif letter6 == "" then
letter6 = string.upper(t)
elseif letter7 == "" then
letter7 = string.upper(t)
elseif letter8 == "" then
letter8 = string.upper(t)
end
end
Result: It will asks the user for an input to the second letter. Then if its done, it will asks the user for an input to the third letter, and so on.
BTW Thanks for all of you guys answers, it helped me a lot