What is it you are trying to achieve?
Continue on to the next procedure if the user clicks in the specified area by using Mouse.Where
What is the problem you are having?
I can't continue onto the next question/procedure
Describe what you have tried to solve this problem
I tried using a "return" statement to return to the original loop with the 1st and 2nd question in it but it doesn't work...
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
import GUI
%DECLARE VARIABLES---------------------------------------------------------------------------------------------------------
%windows
var winID, winL1, winL2, winL3, winCredits, winInstruct : int
%mouse.where
var x, y, b, b1 : int
%pictures
%backgrounds
var picSplash : int := Pic.FileNew ("Splash Screen.jpg")
var picLevel : int := Pic.FileNew ("Level.jpg")
%Questions Level 1
var pic1q0 : int := Pic.FileNew ("Q1-0.jpg")
var pic1q1 : int := Pic.FileNew ("Q1-1.jpg")
var pic1q2 : int := Pic.FileNew ("Q1-2.jpg")
var pic1q3 : int := Pic.FileNew ("Q1-3.jpg")
%font
var fontBradley : int := Font.New ("Bradley Hand ITC:25:bold")
var fontBradleyS : int := Font.New ("Bradley Hand ITC:15:bold")
%Moving Variables
var z : int := 0
var z1, z2, z3, z4 : int
%Radio Buttons
var radio : array 1 .. 5 of int %In order for the radio to be connected it has to be in an array
var pointsC : int := 3
var points : string
var totalPoints : int := 0
var questionCounter : int := 0
var qCounter : string
var correct : int := 0
var level : int := 0
%OPEN WINDOWS--------------------------------------------------------------------------------------------------------------
winID := Window.Open ("position:center;center,graphics:800;600")
View.Set ("title:Music Play")
winL1 := Window.Open ("position:center;center,graphics:800;600")
View.Set ("title:Level 1")
Pic.Draw (picLevel, 0, 0, picCopy)
winL2 := Window.Open ("position:center;center,graphics:800;600")
View.Set ("title:Level 2")
Pic.Draw (picLevel, 0, 0, picCopy)
winL3 := Window.Open ("position:center;center,graphics:800;600")
View.Set ("title:Level 3")
Pic.Draw (picLevel, 0, 0, picCopy)
winCredits := Window.Open ("position:center;center,graphics:800;600")
View.Set ("title:Credits")
Pic.Draw (picLevel, 0, 0, picCopy)
winInstruct := Window.Open ("position:center;center,graphics:800;600")
View.Set ("title:Instructions")
Pic.Draw (picLevel, 0, 0, picCopy)
%Hide the windows
Window.Hide (winL1 )
Window.Hide (winL2 )
Window.Hide (winL3 )
Window.Hide (winCredits )
Window.Hide (winInstruct )
Window.SetActive (winID )
%PROCEDURES----------------------------------------------------------------------------------------------------------------
proc p1
if pointsC = 0 then
Pic.Draw (pic1q0, 0, 0, picCopy)
GUI.Disable (radio (1))
elsif pointsC = 1 then
Pic.Draw (pic1q1, 0, 0, picCopy)
elsif pointsC = 2 then
Pic.Draw (pic1q2, 0, 0, picCopy)
elsif pointsC = 3 then
Pic.Draw (pic1q3, 0, 0, picCopy)
else
end if
GUI.Refresh
if radio (1) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("4>>ed+ed+e<b>dc<1a")
GUI.Disable (radio (2))
GUI.Disable (radio (3))
GUI.Disable (radio (4))
totalPoints := totalPoints + pointsC
correct := correct + 1
%Next Question
Pic.SetTransparentColor (picNextQ, white)
Pic.Draw (picNextQ, 600, 70, picMerge)
Draw.Box (626, 80, 784, 102, red)
View.Update
elsif radio (2) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("1g+f-e-")
pointsC := pointsC - 1
GUI.Disable (radio (2))
elsif radio (3) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("1g+f-e-")
pointsC := pointsC - 1
GUI.Disable (radio (3))
elsif radio (4) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("1g+f-e-")
pointsC := pointsC - 1
GUI.Disable (radio (4))
end if
%Quit Button--------------------------------------------------
loop
Mouse.Where (x, y, b )
if b = 1 then
if
%Quit---------------
x > 712 and x < 780 and y > 25 and y < 54 then
Window.Close (winID )
Window.Close (winL1 )
Window.Close (winL2 )
Window.Close (winL3 )
Window.Close (winCredits )
Window.Close (winInstruct )
quit
else
exit
end if
else
end if
end loop
loop
%Next Question Button----------------------------------------
Mouse.Where (x, y, b )
if b = 1 then
if
%Next Question-----------
x > 626 and x < 784 and y > 80 and y < 102 then
return
else
exit
end if
else
end if
end loop
end p1
proc p2
if pointsC = 0 then
Pic.Draw (pic1q0, 0, 0, picCopy)
GUI.Disable (radio (1))
elsif pointsC = 1 then
Pic.Draw (pic1q1, 0, 0, picCopy)
elsif pointsC = 2 then
Pic.Draw (pic1q2, 0, 0, picCopy)
elsif pointsC = 3 then
Pic.Draw (pic1q3, 0, 0, picCopy)
else
end if
GUI.Refresh
if radio (1) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("4>>ed+ed+e<b>dc<1a")
GUI.Disable (radio (2))
GUI.Disable (radio (3))
GUI.Disable (radio (4))
totalPoints := totalPoints + pointsC
correct := correct + 1
%Next Question
Pic.SetTransparentColor (picNextQ, white)
Pic.Draw (picNextQ, 600, 70, picMerge)
Draw.Box (626, 80, 784, 102, red)
View.Update
elsif radio (2) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("1g+f-e-")
pointsC := pointsC - 1
GUI.Disable (radio (2))
elsif radio (3) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("1g+f-e-")
pointsC := pointsC - 1
GUI.Disable (radio (3))
elsif radio (4) = GUI.GetEventWidgetID then
locate (2, 1)
Music.Play ("1g+f-e-")
pointsC := pointsC - 1
GUI.Disable (radio (4))
end if
%Quit Button--------------------------------------------------
loop
Mouse.Where (x, y, b )
if b = 1 then
if
%Quit---------------
x > 712 and x < 780 and y > 25 and y < 54 then
Window.Close (winID )
Window.Close (winL1 )
Window.Close (winL2 )
Window.Close (winL3 )
Window.Close (winCredits )
Window.Close (winInstruct )
quit
else
exit
end if
else
end if
end loop
loop
%Next Question Button----------------------------------------
Mouse.Where (x, y, b )
if b = 1 then
if
%Next Question-----------
x > 626 and x < 784 and y > 80 and y < 102 then
return
else
exit
end if
else
end if
end loop
end p2
process furElise
%Music
Music.Play ("4>>ed+ed+e<b>dc<2a<4ea>ceab<4eg+>eg+b>1c<<4ea>e>ed+ed+e<b>dc<2a<4ea>ceab<4eg+>eg+b>1c<<4ea>e>ed+ed+e<b>dc<2a<4ea>cea2b<4eg+>e>c<b1a<4ea")
end furElise
fork furElise
%Background
Pic.Draw (picSplash, 0, 0, picCopy)
%MOUSE.WHERE BUTTONS-------------------------------------------------------------------------------------------------------
loop
if level = 0 then
Window.Hide (winL1 )
Window.Hide (winL2 )
Window.Hide (winL3 )
Window.Hide (winCredits )
Window.Hide (winInstruct )
Window.SetActive (winID )
View.Set ("title:Music Play")
%Background
cls
Pic.Draw (picSplash, 0, 0, picCopy)
Mouse.Where (x, y, b )
if b = 1 then
%Quarter
if x > 130 and x < 242 and y > 278 and y < 303 then
level := 1
delay (5)
exit
elsif
%Two Quarter--------
x > 130 and x < 313 and y > 190 and y < 215 then
level := 2
delay (5)
exit
elsif
%Three Quarter------
x > 130 and x < 331 and y > 90 and y < 113 then
level := 3
delay (5)
exit
elsif
%Instruction--------
x > 596 and x < 765 and y > 535 and y < 565 then
level := 4
delay (5)
exit
elsif
%Credits------------
x > 665 and x < 765 and y > 463 and y < 495 then
level := 5
delay (5)
exit
elsif
%Quit---------------
x > 712 and x < 780 and y > 25 and y < 54 then
Window.Close (winID )
Window.Close (winL1 )
Window.Close (winL2 )
Window.Close (winL3 )
Window.Close (winCredits )
Window.Close (winInstruct )
quit
else
end if
else
end if
else
end if
end loop
for questionNumber : 1.. 10
%LEVEL ONE
if level = 1 then
Window.Hide (winID )
Window.Hide (winL2 )
Window.Hide (winL3 )
Window.Hide (winCredits )
Window.Hide (winInstruct )
Window.Show (winL1 )
Window.SetActive (winL1 )
View.Set ("title:Level 1")
if correct = 0 then
%Question 1------------------------------------------------------------------------------------------------------------
%Background
Pic.Draw (pic1q3, 0, 0, picCopy)
%Draw.Box (630, 90, 790, 114, red) %NEXT QUESTION PARAMETRES
View.Update
GUI.Refresh
%Counters
qCounter := intstr (questionCounter )
questionCounter := questionCounter + 1
%BUTTONS----------------------------------------------------------------------------------------
radio (1) := GUI.CreateRadioButtonFull (180, 350, "A Composer", 0, p1, GUI.LEFT, "1")
radio (2) := GUI.CreateRadioButtonFull (180, 300, "A Poet", radio (1), p1, GUI.LEFT, "2")
radio (3) := GUI.CreateRadioButtonFull (180, 250, "An Artist", radio (2), p1, GUI.LEFT, "3")
radio (4) := GUI.CreateRadioButtonFull (180, 200, "Nobody Special", radio (3), p1, GUI.LEFT, "4")
%Make dummy radio button to hide from view
radio (5) := GUI.CreateRadioButtonFull (1000, 150, "", radio (4), p1, GUI.LEFT, "4")
%select button
GUI.SelectRadio (radio (5))
%Hide Button from User
GUI.Hide (radio (5))
View.Update
elsif correct = 1 then
%Question 2------------------------------------------------------------------------------------------------------------
%Background
Pic.Draw (pic1q3, 0, 0, picCopy)
%Draw.Box (630, 90, 790, 114, red) %NEXT QUESTION PARAMETRES
View.Update
GUI.Refresh
%Counters
qCounter := intstr (questionCounter )
questionCounter := questionCounter + 1
%BUTTONS----------------------------------------------------------------------------------------
radio (1) := GUI.CreateRadioButtonFull (180, 350, "A famous Composer", 0, p2, GUI.LEFT, "1")
radio (2) := GUI.CreateRadioButtonFull (180, 300, "A Poet", radio (1), p2, GUI.LEFT, "2")
radio (3) := GUI.CreateRadioButtonFull (180, 250, "An Artist", radio (2), p2, GUI.LEFT, "3")
radio (4) := GUI.CreateRadioButtonFull (180, 200, "Nobody Special", radio (3), p2, GUI.LEFT, "4")
%Make dummy radio button to hide from view
radio (5) := GUI.CreateRadioButtonFull (1000, 150, "", radio (4), p2, GUI.LEFT, "4")
%select button
GUI.SelectRadio (radio (5))
%Hide Button from User
GUI.Hide (radio (5))
View.Update
else
end if
else
end if
loop
exit when GUI.ProcessEvent
end loop
|
Please specify what version of Turing you are using
Turing 4.1.1 |