Computer Science Canada Can pictures be used in/as an array? |
Author: | NEEDSHELP [ Tue Jun 09, 2009 9:31 pm ] |
Post subject: | Can pictures be used in/as an array? |
I have previously asked this question and I will attempt to ask it again hoping to have some answer of some sort: can you use pictures in an array and how can one do so? (an example or two would be greatly appreciated...) thnkx... |
Author: | DtY [ Tue Jun 09, 2009 9:42 pm ] | ||
Post subject: | RE:Can pictures be used in/as an array? | ||
(correct me if I'm wrong...) In Turing, images/sprites aren't actually images/sprites as they are in other languages, they are just integers representing the loaded image, so you can make an array of integers, and load stuff into it:
You can also use a loop to load them, which is probably why you want them in an array. |
Author: | NEEDSHELP [ Tue Jun 09, 2009 10:22 pm ] |
Post subject: | Re: Can pictures be used in/as an array? |
okie, so your help really cleared things up for me however, when i try to get a loop to simplify things, a problem arises in my code like so: loop put qst(x) delay(500) put "A) ", OptA(x) put "B) ", OptB(x) put "C) ", OptC(x) put "D) ", OptD(x) put "" Pic.Draw (pics(x), 200, 300, picCopy) [i]this is where the problem arises for turing tells me that it was an "Illegal picture ID number '0' saying that the probable cause was that the picture was not sucessfully created." get guess if guess = aswr(x) then put "Correct!" elsif guess not= aswr(x) then put "That's wrong!" end if x:= x+1 exit when x = 8 end loop i've tried figuring out why such a statement appears like so but haven't been able to find any answers. here's my whole code so far: var qst :array 1 .. 8 of string var OptA :array 1 .. 8 of string var OptB :array 1 .. 8 of string var OptC :array 1 .. 8 of string var OptD :array 1 .. 8 of string var aswr :array 1 .. 8 of string var guess :string var pics :array 1 .. 8 of int var x :int:= 1 qst(1) := "To which animal does this eye belong to?" qst(2) := "What about this one?" qst(3) := "I see you... this is an eye of..." qst(4) := "LOOK AT ME! Which animal now?" qst(5) := "This is an eye?! But, who's?" qst(6) := "And this one?" qst(7) := "What animal has such a eye?" qst(8) := "Ohh, pretty... Who has these?" OptA(1):="Snake"; OptB(1):="Salmon"; OptC(1):="Desert Lizard"; OptD(1):="Frog" OptA(2):="Porcupine"; OptB(2):="Cat"; OptC(2):="Dog"; OptD(2):="Wolf Cub" OptA(3):="Lion"; OptB(3):="Wolverine"; OptC(3):="Antelope"; OptD(3):="Giraffe" OptA(4):="White Wolf"; OptB(4):="Polar Bear"; OptC(4):="Owl"; OptD(4):="Arctic Fox" OptA(5):="Jellyfish"; OptB(5):="Sea Cucumber"; OptC(5):="Octopus"; OptD(5):="Hippopotamus" OptA(6):="Crocodile"; OptB(6):="Frog"; OptC(6):="Salamander"; OptD(6):="Eel" OptA(7):="Ostrich"; OptB(7):="Rhinocerous"; OptC(7):="Turkey"; OptD(7):="Turtle" OptA(8):="Lemur"; OptB(8):="Jumping Spider"; OptC(8):="Angler Fish"; OptD(8):="Caterpillar" aswr(1) := "A" aswr(2) := "C" aswr(3) := "A" aswr(4) := "C" aswr(5) := "C" aswr(6) := "B" aswr(7) := "D" aswr(8) := "B" pics(1):= Pic.FileNew("eye1.bmp") pics(2):= Pic.FileNew ("eye2.bmp") pics(3):= Pic.FileNew ("eye3.bmp") pics(4):= Pic.FileNew ("eye4.bmp") pics(5):= Pic.FileNew ("eye5.bmp") pics(6):= Pic.FileNew ("eye6.bmp") pics(7):= Pic.FileNew ("eye7.bmp") pics(8):= Pic.FileNew ("eye8.bmp") Draw.Fill (500,300,7,7) colourback (7) colour (0) loop put qst(x) delay(500) put "A) ", OptA(x) put "B) ", OptB(x) put "C) ", OptC(x) put "D) ", OptD(x) put "" Pic.Draw (pics(x), 200, 300, picCopy) get guess if guess = aswr(x) then put "Correct!" elsif guess not= aswr(x) then put "That's wrong!" end if x:= x+1 exit when x = 8 end loop if anyone, ANYONE, could figue out why my program is not working and how i could fix it, i would be most grateful... thank you.. |
Author: | Tony [ Wed Jun 10, 2009 11:56 am ] |
Post subject: | RE:Can pictures be used in/as an array? |
my first guess, based on the error message, is that the image is simply isn't loaded. You can check what Pic.FileNew("eye1.bmp") returns. Some common reasons is that the image name is either misspelled or the file is located in a different folder than your program is looking in. |
Author: | BigBear [ Wed Jun 10, 2009 1:58 pm ] | ||
Post subject: | RE:Can pictures be used in/as an array? | ||
here is a method of using pictures in a for loop taken from this tutorial http://compsci.ca/v3/viewtopic.php?t=4637&highlight=gif |
Author: | DtY [ Wed Jun 10, 2009 3:46 pm ] |
Post subject: | RE:Can pictures be used in/as an array? |
That doesn't use an array though... |
Author: | NEEDSHELP [ Wed Jun 10, 2009 9:43 pm ] |
Post subject: | RE:Can pictures be used in/as an array? |
thanks for all the help ideas guys... turns out that Toni was right... my pictures weren't located in the same folder as my application thus giving me that error message... +_+ wow, what a simpleton i was... thankfully, i learned my lesson and, my project was completed (and worked) successfully with all your help thanks again! |