Numerous Buttons used to switch procedures
Author |
Message |
Gaming Lyfe
|
Posted: Tue Dec 29, 2015 4:39 pm Post subject: Numerous Buttons used to switch procedures |
|
|
What is it you are trying to achieve?
I am trying to create a program where buttons are used between different sections of the code.
What is the problem you are having?
I have tried and tried but i cant seem to get the buttons to work.
Describe what you have tried to solve this problem
I have read multiple tutorials and similar help posts but i haven't been able to solve this problem. I have rearranged the code and tried placing it in different places but that hasn't worked either
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
import GUI
procedure pauseProgram
var reply : string (1)
put ""
put "Press any key to continue...." ..
getch (reply )
end pauseProgram
procedure animation
drawfillbox (0, 0, 640, 400, green)
for i : 1 .. 600
drawfilloval (25 + i, 25, 21, 21, green)
drawfilloval (25 + i, 25, 20, 20, brightred)
delay (5)
end for
for i : 1 .. 360
drawfilloval (625, 25 + i, 21, 21, green)
drawfilloval (625, 25 + i, 20, 20, brightred)
delay (5)
end for
for i : 1 .. 600
drawfilloval (625 - i, 385, 21, 21, green)
drawfilloval (625 - i, 385, 20, 20, brightred)
delay (5)
end for
for i : 1 .. 260
drawfilloval (25, 385 - i, 21, 21, green)
drawfilloval (25, 385 - i, 20, 20, brightred)
delay (5)
end for
for i : 1 .. 500
drawfilloval (25 + i, 125, 21, 21, green)
drawfilloval (25 + i, 125, 20, 20, brightred)
delay (5)
end for
for i : 1 .. 150
drawfilloval (525, 125 + i, 21, 21, green)
drawfilloval (525, 125 + i, 20, 20, brightred)
delay (5)
end for
for i : 1 .. 600
drawfilloval (525 - i, 275, 21, 21, green)
drawfilloval (525 - i, 275, 20, 20, brightred)
delay (5)
end for
var font1 : int
font1 := Font.New ("timesnewroman:40") %font 1
Font.Draw ("Simon Says", 210, 180, font1, brightred)
delay (3000)
end animation
procedure intro
cls
locate (4, 17)
put "Welcome to Simon Says, a game where memory is key!"
locate (6, 18)
put "Remember the colours and their order! Good Luck!"
locate (12, 23)
put "Press the Menu button to continue."
end intro
proc instruct
cls
locate (4, 7)
put "In Simon Says, there is a colour wheel that contains eight sections."
locate (6, 14)
put "Eight colours will flash in eight random positions!"
locate (8, 10)
put "Remember the clockwise order of which colours flash to win!"
end instruct
procedure simonSays
var pickedAlready : array 1 .. 8 of boolean
var randSpace, counter, randColor, coloring, space : int := 0
cls
drawoval (400, 175, 125, 125, black)
drawline (400, 175, 525, 175, black)
drawline (400, 175, 275, 175, black)
drawline (400, 175, 400, 300, black)
drawline (400, 175, 400, 50, black)
drawline (400, 175, 488, 263, black)
drawline (400, 175, 315, 85, black)
drawline (400, 175, 314, 264, black)
drawline (400, 175, 488, 85, black)
for i : 1 .. 8
pickedAlready (i ) := false
end for
loop
randint (randColor, 1, 8)
if randColor = 1 then
coloring := 14 %Yellow
elsif randColor = 2 then
coloring := 12 %Red
elsif randColor = 3 then
coloring := 10 %Green
elsif randColor = 4 then
coloring := 13 %Pink
elsif randColor = 5 then
coloring := 35 %Purple
elsif randColor = 6 then
coloring := 42 %Orange
elsif randColor = 7 then
coloring := 76 %Light Blue
elsif randColor = 8 then
coloring := 1 %Blue
end if
randint (randSpace, 1, 8)
if pickedAlready (randSpace ) = false then
if randSpace = 1 then
drawfill (425, 225, coloring, black)
delay (1000)
drawfill (425, 225, white, black)
elsif randSpace = 2 then
drawfill (450, 180, coloring, black)
delay (1000)
drawfill (450, 180, white, black)
elsif randSpace = 3 then
drawfill (450, 170, coloring, black)
delay (1000)
drawfill (450, 170, white, black)
elsif randSpace = 4 then
drawfill (425, 125, coloring, black)
delay (1000)
drawfill (425, 125, white, black)
elsif randSpace = 5 then
drawfill (375, 125, coloring, black)
delay (1000)
drawfill (375, 125, white, black)
elsif randSpace = 6 then
drawfill (350, 180, coloring, black)
delay (1000)
drawfill (350, 180, white, black)
elsif randSpace = 7 then
drawfill (350, 170, coloring, black)
delay (1000)
drawfill (350, 170, white, black)
elsif randSpace = 8 then
drawfill (375, 225, coloring, black)
delay (1000)
drawfill (375, 225, white, black)
end if
counter + = 1
pickedAlready (randSpace ) := true
end if
exit when counter = 8
end loop
end simonSays
proc ssAnswers
locate(2, 5)
put"In which clockwise order did the colours flash?"
end ssAnswers
proc goodBye
locate(2, 27)
put"Thanks for playing Simon Says!"
locate(4, 32)
put"Have a great day!"
locate(12, 30)
put"This program was made by:"
locate(13, 36)
put"Wyatt Currie"
end goodBye
goodBye
ssAnswers
intro
var button1 : int := GUI.CreateButton (290, 20, 0, "Instructions", instruct )
loop
exit when GUI.ProcessEvent
end loop
var button2 : int := GUI.CreateButton (292, 50, 0, "Play Game", simonSays )
loop
exit when GUI.ProcessEvent
end loop
|
Please specify what version of Turing you are using
Latest version!
Please help me, or provide insight into what i am doing wrong! Thanks! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Wed Dec 30, 2015 6:56 pm Post subject: RE:Numerous Buttons used to switch procedures |
|
|
Your Instructions button works fine for me. The Play Game button is never created, because the first loop never exits. GUI.ProcessEvent only returns true when the procedure GUI.Quit is called. You never call GUI.Quit. You could create a button where GUI.Quit is its associated action procedure, or you could add it to the end of the instruct procedure. Either way, you need to add GUI.Quit somewhere so that your loop will exit, so that the 2nd button can be created and the 2nd loop can be executed. |
|
|
|
|
|
|
|