Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- juanPonce1={"Question", "Answer1", "Answer2", "Answer3", "Answer2"} --Table with certain question about Juan Ponce de Leon. 3rd level.
- juanPonce={juanPonce1} --Table with all questions about Juan Ponce de Leon. 2ed level.
- questionsAndAnswers={juanPonce} --Ttable with all the question. 1st level.
- height=love.graphics.getHeight() --Finds the height and width for later.
- width=love.graphics.getWidth()
- ButtonPressed=false --Whether the button is pressed or not
- ButtonDown=love.graphics.newImage("Button2.png") --Creates our images.
- ButtonUp=love.graphics.newImage("Button1.png")
- ButtonColored=love.graphics.newImage("Button3.png")
- love.graphics.setIcon(love.graphics.newImage("Button1Logo.png")) --Makes our logo.
- answer="" --Current answer.
- seconds=0 --Time stuffz.
- secondsRequired=false
- mouseX=0 --Mouse stuffz.
- mouseY=0
- buttonWidth=ButtonUp:getWidth()*(1/4) --Width and height of scaled buttons.
- buttonHeight=ButtonUp:getHeight()*(1/4)
- Button1Text="" --Stuff for answers next to buttons.
- Button2Text=""
- Button3Text=""
- question=""
- end
- function love.update(dt)
- if secondsRequired then
- seconds=seconds+dt
- end
- mouseX=love.mouse.getX() --Update the mouse.
- mouseY=love.mouse.getY()
- if (mouseX>=formula(1/8, 0.25)) and (mouseX<=formula(1/8, 0.25)+buttonWidth) and (mouseY>=formula(1/4, 0.25)) and (mouseY<=formula(1/4, 0.25)+buttonHeight) then --if is in the box of this image then
- if love.mouse.isDown("l") then --If this image ios clicked on then
- currentButton1=ButtonDown
- else
- currentButton1=ButtonColored --If this image is hovered over then
- end
- else
- currentButton1=ButtonUp --If this image is not hovered over then
- end
- if (mouseX>=formula(1/8, 0.25)) and (mouseX<=formula(1/8, 0.25)+buttonWidth) and (mouseY>=formula(2/4, 0.25)) and (mouseY<=formula(2/4, 0.25)+buttonHeight) then --if is in the box of this image then
- if love.mouse.isDown("l") then --If this image ios clicked on then
- currentButton2=ButtonDown
- else
- currentButton2=ButtonColored --If this image is hovered over then
- end
- else
- currentButton2=ButtonUp --If this image is not hovered over then
- end
- if (mouseX>=formula(1/8, 0.25)) and (mouseX<=formula(1/8, 0.25)+buttonWidth) and (mouseY>=formula(3/4, 0.25)) and (mouseY<=formula(3/4, 0.25)+buttonHeight) then --if is in the box of this image then
- if love.mouse.isDown("l") then --If this image ios clicked on then
- currentButton3=ButtonDown
- else
- currentButton3=ButtonColored --If this image is hovered over then
- end
- else
- currentButton3=ButtonUp --If this image is not hovered over then
- end
- for i, level2 in pairs(questionsAndAnswers) do
- for i2, level3 in pairs(level2) do
- if i2==1 then
- question=level3[i2]
- elseif i2==2 then
- Button1Text=level3[i2]
- elseif i2==3 then
- Button2Text=level3[i2]
- elseif i2==4 then
- Button3Text=level3[i2]
- else
- answer=level3[i2]
- end
- end
- end
- end
- function love.draw()
- love.graphics.draw(currentButton1, formula(1/8, 0.25), formula(1/4, 0.25), 0, 0.25) --The position is a formula to make the center of the image go to the desired spot, instead of the top left corner.
- love.graphics.print(Button1Text, formula(1/8, 0.25)+75, formula(1/4, 0.25)+12.5)
- love.graphics.draw(currentButton2, formula(1/8, 0.25), formula(2/4, 0.25), 0, 0.25)
- love.graphics.print(Button2Text, formula(1/8, 0.25)+75, formula(1/4, 0.25)-12.5)
- love.graphics.draw(currentButton3, formula(1/8, 0.25), formula(3/4, 0.25), 0, 0.25)
- love.graphics.print(Button3Text, formula(1/8, 0.25)+75, formula(1/4, 0.25)-12.5)
- love.graphics.print(question, width/2-#question, height/8, 0, 2)
- print(answer)
- end
- function formula(position, scale)
- return (height*position)-((buttonHeight*scale)/2) --Formula. I'm proud of myself :D
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement