Storing the data from randints for later use
Author |
Message |
GamingLyfe2
|
Posted: Thu Jan 14, 2016 2:02 pm Post subject: Storing the data from randints for later use |
|
|
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!!!!! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Thu Jan 14, 2016 6:31 pm Post subject: RE:Storing the data from randints for later use |
|
|
I think the easiest method would be to generate all of your random numbers in advance and store them in an array, instead of generating them on the fly when you need them. For example,
code: | for i : 0..10
randint (array, 1, 8)
end for |
Now you have 10 random numbers. When you want to draw them, just use a loop to go over the array.
code: | for i : 0..10
Draw.FillOval (100, 100, 10, 10, array(i))
end for |
And when you check the input from the user, use another for loop that checks the array to see if it's correct.
code: | for i : 0..10
get input
if input not= array(i) then
exit
end if
end for |
|
|
|
|
|
|
Gaming Lyfe
|
Posted: Fri Jan 15, 2016 8:53 pm Post subject: RE:Storing the data from randints for later use |
|
|
I used this and I did this code but it always says argument is wrong type. I tried to firgure it out but i couldnt seem to fix the error.
var hi : array 0 .. 8 of int
for i : 0 .. 8
randint (hi, 1, 8)
drawfilloval (100, 100, 10, 10, hi(i))
end for |
|
|
|
|
|
Insectoid
|
Posted: Sun Jan 17, 2016 5:48 pm Post subject: RE:Storing the data from randints for later use |
|
|
Have you learned arrays yet? Your syntax is wrong on line 3 (and it was wrong in my example, so I don't blame you).
Should be:
randint (hi(i), 1, 8) |
|
|
|
|
|
Gaming Lyfe
|
Posted: Sun Jan 17, 2016 7:42 pm Post subject: RE:Storing the data from randints for later use |
|
|
Im so stupid! its so obvious. I have learned arrays and i have to specify that i want to generate them one at a time because it needs to generate 8! Thanks so much!!!
+ Bits |
|
|
|
|
|
Gaming Lyfe
|
Posted: Sun Jan 17, 2016 7:58 pm Post subject: RE:Storing the data from randints for later use |
|
|
var col : array 1 .. 8 of int
var ans: int
for i : 1 .. 8
randint (col (i), 1, 8)
put col(i)
end for
for i : 0..8
get ans
if ans not= col(i) then
exit
end if
end for
I get the error "Array Subscript is out of Range". I checked tutorials and help forums and couldnt find anything... could anyone help? |
|
|
|
|
|
Gaming Lyfe
|
Posted: Sun Jan 17, 2016 10:25 pm Post subject: URGENT! Array, RandInt Help For ISP Simon Game |
|
|
I am trying to create a game where a color wheel flashes random colors and the user has to guess them. I am almost done , but i isolated this section of the code to deal with it. I cant get the color to change because not matter what i tried the first color that flashes is always right and the rest are wrong. I could loop it 8 times using the for loop but it doesnt fix the problem, it just makes me enter all 8 answers 8 times, with X try the answer is the X number that flashed! I am stuck on this and need help!!! Please Help Me!!!!!!!!!!
Turing: |
import GUI
var button1 : int
var button2 : int
var button3 : int
var button4 : int
var button5 : int
var button6 : int
var button7 : int
var button8 : int
var font1 : int
var maniWin : int
font1 := Font.New ("timesnewroman:15")
var background : int := Pic.FileNew ("b1.bmp")
var c1, c2, c3, c4, c5, c6, c7, c8 : string
var a : string
var a1 : int
var counter3 : int := 0
var mainWin := Window.Open ("position:300;300, graphics:640;400")
var col : array 1 .. 8 of int
var ans : int
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
for i : 1 .. 8
loop
randint (col (i ), 1, 8)
if col (i ) = 1 then
coloring := 14 %Yellow
elsif col (i ) = 2 then
coloring := 12 %Red
elsif col (i ) = 3 then
coloring := 10 %Green
elsif col (i ) = 4 then
coloring := 13 %Pink
elsif col (i ) = 5 then
coloring := 35 %Purple
elsif col (i ) = 6 then
coloring := 42 %Orange
elsif col (i ) = 7 then
coloring := 76 %Light Blue
elsif col (i ) = 8 then
coloring := 1 %Blue
end if
randint (randSpace, 1, 8)
if pickedAlready (randSpace ) = false then
if randSpace = 1 then
drawfill (425 - 79, 225 + 24, coloring, black)
delay (1000)
drawfill (425 - 79, 225 + 24, white, black)
elsif randSpace = 2 then
drawfill (450 - 79, 180 + 24, coloring, black)
delay (1000)
drawfill (450 - 79, 180 + 24, white, black)
elsif randSpace = 3 then
drawfill (450 - 79, 170 + 24, coloring, black)
delay (1000)
drawfill (450 - 79, 170 + 24, white, black)
elsif randSpace = 4 then
drawfill (425 - 79, 125 + 24, coloring, black)
delay (1000)
drawfill (425 - 79, 125 + 24, white, black)
elsif randSpace = 5 then
drawfill (375 - 79, 125 + 24, coloring, black)
delay (1000)
drawfill (375 - 79, 125 + 24, white, black)
elsif randSpace = 6 then
drawfill (350 - 79, 180 + 24, coloring, black)
delay (1000)
drawfill (350 - 79, 180 + 24, white, black)
elsif randSpace = 7 then
drawfill (350 - 79, 170 + 24, coloring, black)
delay (1000)
drawfill (350 - 79, 170 + 24, white, black)
elsif randSpace = 8 then
drawfill (375 - 79, 225 + 24, coloring, black)
delay (1000)
drawfill (375 - 79, 225 + 24, white, black)
end if
counter + = 1
pickedAlready (randSpace ) := true
end if
exit when counter = 8
end loop
end for
end simonSays1
proc ssAnswers
cls
drawfillbox (0, 0, 640, 400, 76)
Font.Draw ("In what order did the colours flash?", 10, 380, font1, 37)
for i : 1 .. 1
Font.Draw ("What was Colour 1:", 10, 350, font1, 37)
locate (3, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 not= col (i ) then
locate (20, 60)
put "wrong"
elsif a1 = col (i ) then
locate (20, 60)
put "right"
end if
end for
for i : 1 .. 1
Font.Draw ("What was Colour 2:", 10, 320, font1, 37)
locate (5, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 = col (i ) then
locate (20, 60)
put "right"
else
locate (20, 60)
put "wrong"
end if
end for
for i : 1 .. 1
Font.Draw ("What was Colour 3:", 10, 290, font1, 37)
locate (7, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 not= col (i ) then
locate (20, 60)
put "wrong"
elsif a1 = col (i ) then
locate (20, 60)
put "right"
end if
end for
for i : 1 .. 1
Font.Draw ("What was Colour 4:", 10, 260, font1, 37)
locate (9, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 not= col (i ) then
locate (20, 60)
put "wrong"
elsif a1 = col (i ) then
locate (20, 60)
put "right"
end if
end for
for i : 1 .. 1
Font.Draw ("What was Colour 5:", 10, 230, font1, 37)
locate (11, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 not= col (i ) then
locate (20, 60)
put "wrong"
elsif a1 = col (i ) then
locate (20, 60)
put "right"
end if
end for
for i : 1 .. 1
Font.Draw ("What was Colour 6:", 10, 200, font1, 37)
locate (13, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 not= col (i ) then
locate (20, 60)
put "wrong"
elsif a1 = col (i ) then
locate (20, 60)
put "right"
end if
end for
for i : 1 .. 1
Font.Draw ("What was Colour 7", 10, 170, font1, 37)
locate (15, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 not= col (i ) then
locate (20, 60)
put "wrong"
elsif a1 = col (i ) then
locate (20, 60)
put "right"
end if
end for
for i : 1 .. 1
Font.Draw ("What was Colour 8:", 10, 140, font1, 37)
locate (17, 25)
get a
if a = "yellow" then
a1 := 1
elsif a = "red" then
a1 := 2
elsif a = "green" then
a1 := 3
elsif a = "pink" then
a1 := 4
elsif a = "purple" then
a1 := 5
elsif a = "orange" then
a1 := 6
elsif a = "light blue" then
a1 := 7
elsif a = "blue" then
a1 := 8
end if
if a1 = col (i ) then
locate (20, 60)
put "right"
else
locate (20, 60)
put "wrong"
end if
end for
for i : 1 .. 8
counter3 + = 1
exit when counter3 = 1
end for
end ssAnswers
simonSays1
ssAnswers
|
|
|
|
|
|
|
Insectoid
|
Posted: Mon Jan 18, 2016 6:08 am Post subject: RE:Storing the data from randints for later use |
|
|
'Array Subscript is out of Range' means you are trying to access part of an array that doesn't exist. For example, if you try to access a(0) where a is of type array 1..8, you will get this error.
As for your other error, well, how many times will this loop execute?
for i : 1..1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Gaming Lyfe
|
Posted: Mon Jan 18, 2016 7:50 am Post subject: RE:Storing the data from randints for later use |
|
|
once |
|
|
|
|
|
Gaming Lyfe
|
Posted: Mon Jan 18, 2016 10:53 am Post subject: RE:Storing the data from randints for later use |
|
|
Thank you so much for all your help!!!!!! I cant thank you enough, you have literally given me what i need to complete my ISP worth 10%! You are the best!
+Bits |
|
|
|
|
|
|
|