What is it you are trying to achieve?
I am trying to create a game where there is a color wheel and 8 random color flash 8 times. The user then has to remember the colors and input them.
What is the problem you are having?
I cant figure out how to store the different colors that flash
Describe what you have tried to solve this problem
if counter = 1 and coloring = 1
then a1 = "yellow"
That didnt work. i tried to fix it multiple other times but they all failed
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
% var colors : int
% var randColor : int
% var counter : int := 0
% var space :int
% var pickedAlready : array 1 .. 8 of boolean
% for i : 1 .. 8
% pickedAlready (i) := false
% end for
% loop
% randint (colors, 1, 8)
% if pickedAlready (colors) = false then
% if colors = 1 then
% randColor := 14 %Yellow
% elsif colors = 2 then
% randColor := 12 %Red
% elsif colors = 3 then
% randColor := 10 %Green
% elsif colors = 4 then
% randColor := 13 %Pink
% elsif colors = 5 then
% randColor := 35 %Purple
% elsif colors = 6 then
% randColor := 42 %Orange
% elsif colors = 7 then
% randColor := 76 %Light Blue
% elsif colors = 8 then
% randColor := 1 %Blue
% end if
%
% end if
% counter += 1
% exit when counter = 8
% pickedAlready(colors):= true
% end if
% end loop
import GUI
var button1 : int
var button2 : int
var button3 : int
var button4 : int
var button5 : int
var button6 : int
var button7 : int
var font1 : int
font1 := Font.New ("timesnewroman:15")
var background : int := Pic.FileNew ("b1.bmp")
var a1, a2, a3, a4, a5, a6, a7, a8 : int
forward procedure pauseProgram
forward procedure animation
forward procedure menu
forward procedure intro
forward procedure instruct
forward procedure simonSays1
forward procedure ssAnswers
forward procedure goodBye
forward procedure simonSays2
forward procedure simonSays3
forward procedure difficult
body proc pauseProgram
var reply : string (1)
put ""
put "Press any key to continue...." ..
getch (reply )
end pauseProgram
body proc animation
for i : 1 .. 400
drawfillbox (0, 0 + i, 80, 0 + i, 14)
delay (1)
end for
for i : 1 .. 400
drawfillbox (80, 0 + i, 160, 0 + i, 12)
delay (1)
end for
for i : 1 .. 400
drawfillbox (160, 0 + i, 240, 0 + i, 10)
delay (1)
end for
for i : 1 .. 400
drawfillbox (240, 0 + i, 320, 0 + i, 13)
delay (1)
end for
for i : 1 .. 400
drawfillbox (320, 0 + i, 400, 0 + i, 35)
delay (1)
end for
for i : 1 .. 400
drawfillbox (400, 0 + i, 480, 0 + i, 42)
delay (1)
end for
for i : 1 .. 400
drawfillbox (480, 0 + i, 560, 0 + i, 76)
delay (1)
end for
for i : 1 .. 400
drawfillbox (560, 0 + i, 640, 0 + i, 1)
delay (1)
end for
var font2 : int
font2 := Font.New ("timesnewroman:40")
Font.Draw ("Simon Says", 210, 180, font2, black)
delay (4000)
end animation
body proc menu
cls
GUI.Hide (button1 )
Pic.Draw (background, - 50, 0, 0)
button2 := GUI.CreateButton (290, 20, 0, "Instructions", instruct )
button3 := GUI.CreateButton (292, 50, 0, "Play Game", difficult )
button4 := GUI.CreateButton (297, 80, 0, "Exit", goodBye )
end menu
body proc intro
cls
Pic.Draw (background, - 50, 0, 0)
Font.Draw ("Welcome to Simon Says, a game where memory is key!", 100, 330, font1, brightblue)
Font.Draw ("Remember the colours and their order! Good Luck!", 120, 300, font1, yellow)
Font.Draw ("Press the Menu button to continue.", 180, 200, font1, brightgreen)
button1 := GUI.CreateButton (500, 30, 0, "Menu", menu )
end intro
body proc instruct
cls
Pic.Draw (background, - 50, 0, 0)
GUI.Show (button1 )
Font.Draw ("In Simon Says, there is a colour wheel that contains eight sections.", 25, 330, font1, brightblue)
Font.Draw ("Eight colours will flash in eight random positions!", 100, 300, font1, yellow)
Font.Draw ("Remember the order of which colours flash to win!", 90, 270, font1, white)
Font.Draw ("Press the Menu button to continue.", 180, 200, font1, brightgreen)
end instruct
body proc simonSays1
var pickedAlready : array 1 .. 8 of boolean
var randSpace, counter, randColor, coloring, space : int := 0
cls
Pic.Draw (background, - 50, 0, 0)
drawfilloval (320, 200, 125, 125, white)
drawoval (320, 200, 125, 125, black)
drawline (320, 200, 525 - 80, 175 + 25, black)
drawline (320, 200, 275 - 80, 175 + 25, black)
drawline (320, 200, 400 - 80, 300 + 25, black)
drawline (320, 200, 400 - 80, 50 + 25, black)
drawline (320, 200, 488 - 80, 263 + 25, black)
drawline (320, 200, 315 - 80, 85 + 25, black)
drawline (320, 200, 314 - 80, 264 + 25, black)
drawline (320, 200, 488 - 80, 85 + 25, 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 simonSays1
body proc simonSays3
var pickedAlready : array 1 .. 8 of boolean
var randSpace, counter, randColor, coloring, space : int := 0
cls
Pic.Draw (background, - 50, 0, 0)
drawfilloval (320, 200, 125, 125, white)
drawoval (320, 200, 125, 125, black)
drawline (320, 200, 525 - 80, 175 + 25, black)
drawline (320, 200, 275 - 80, 175 + 25, black)
drawline (320, 200, 400 - 80, 300 + 25, black)
drawline (320, 200, 400 - 80, 50 + 25, black)
drawline (320, 200, 488 - 80, 263 + 25, black)
drawline (320, 200, 315 - 80, 85 + 25, black)
drawline (320, 200, 314 - 80, 264 + 25, black)
drawline (320, 200, 488 - 80, 85 + 25, 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 (500)
drawfill (425, 225, white, black)
elsif randSpace = 2 then
drawfill (450, 180, coloring, black)
delay (500)
drawfill (450, 180, white, black)
elsif randSpace = 3 then
drawfill (450, 170, coloring, black)
delay (500)
drawfill (450, 170, white, black)
elsif randSpace = 4 then
drawfill (425, 125, coloring, black)
delay (500)
drawfill (425, 125, white, black)
elsif randSpace = 5 then
drawfill (375, 125, coloring, black)
delay (500)
drawfill (375, 125, white, black)
elsif randSpace = 6 then
drawfill (350, 180, coloring, black)
delay (500)
drawfill (350, 180, white, black)
elsif randSpace = 7 then
drawfill (350, 170, coloring, black)
delay (500)
drawfill (350, 170, white, black)
elsif randSpace = 8 then
drawfill (375, 225, coloring, black)
delay (500)
drawfill (375, 225, white, black)
end if
counter + = 1
pickedAlready (randSpace ) := true
end if
exit when counter = 8
end loop
end simonSays3
body proc simonSays2
var pickedAlready : array 1 .. 8 of boolean
var randSpace, counter, randColor, coloring, space : int := 0
cls
Pic.Draw (background, - 50, 0, 0)
drawfilloval (320, 200, 125, 125, white)
drawoval (320, 200, 125, 125, black)
drawline (320, 200, 525 - 80, 175 + 25, black)
drawline (320, 200, 275 - 80, 175 + 25, black)
drawline (320, 200, 400 - 80, 300 + 25, black)
drawline (320, 200, 400 - 80, 50 + 25, black)
drawline (320, 200, 488 - 80, 263 + 25, black)
drawline (320, 200, 315 - 80, 85 + 25, black)
drawline (320, 200, 314 - 80, 264 + 25, black)
drawline (320, 200, 488 - 80, 85 + 25, 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 (750)
drawfill (425, 225, white, black)
elsif randSpace = 2 then
drawfill (450, 180, coloring, black)
delay (750)
drawfill (450, 180, white, black)
elsif randSpace = 3 then
drawfill (450, 170, coloring, black)
delay (750)
drawfill (450, 170, white, black)
elsif randSpace = 4 then
drawfill (425, 125, coloring, black)
delay (750)
drawfill (425, 125, white, black)
elsif randSpace = 5 then
drawfill (375, 125, coloring, black)
delay (750)
drawfill (375, 125, white, black)
elsif randSpace = 6 then
drawfill (350, 180, coloring, black)
delay (750)
drawfill (350, 180, white, black)
elsif randSpace = 7 then
drawfill (350, 170, coloring, black)
delay (750)
drawfill (350, 170, white, black)
elsif randSpace = 8 then
drawfill (375, 225, coloring, black)
delay (750)
drawfill (375, 225, white, black)
end if
counter + = 1
pickedAlready (randSpace ) := true
end if
exit when counter = 8
end loop
end simonSays2
body proc difficult
cls
GUI.Hide (button1 )
GUI.Hide (button2 )
GUI.Hide (button3 )
GUI.Hide (button4 )
Pic.Draw (background, - 50, 0, 0)
button1 := GUI.CreateButton (500, 30, 0, "Menu", menu )
button5 := GUI.CreateButton (300, 240, 0, "Easy", simonSays1 )
button6 := GUI.CreateButton (290, 200, 0, "Medium", simonSays2 )
button7 := GUI.CreateButton (300, 160, 0, "Hard", simonSays3 )
end difficult
body proc ssAnswers
cls
locate (2, 5)
put "In which order did the colours flash?"
end ssAnswers
body proc goodBye
cls
var counter2 : int
GUI.Quit
GUI.Hide (button1 )
GUI.Hide (button2 )
GUI.Hide (button3 )
GUI.Hide (button4 )
Pic.Draw (background, - 50, 0, 0)
loop
Font.Draw ("Thanks for playing Simon Says!", 175, 330, font1, brightblue)
Font.Draw ("Have a great day!", 210, 300, font1, yellow)
Font.Draw ("This program was made by:", 60, 100, font1, brightgreen)
Font.Draw ("Wyatt Currie", 65, 70, font1, brightred)
counter2 := + 1
exit when counter2 = 1
end loop
end goodBye
animation
intro
loop
exit when GUI.ProcessEvent
end loop
|
Please specify what version of Turing you are using
Latest Version
P.S. You obviously don't have the images so you can comment those out if you want to try the code. Thanks!!!!! |