Computer Science Canada Picture guessing game help for turing |
Author: | anchor [ Sun Jan 20, 2013 11:59 am ] | ||
Post subject: | Picture guessing game help for turing | ||
What is it you are trying to achieve? <Trying to create an efficient picture guessing game where a picture will be drawn to screen, and the user has to guess what it is.> What is the problem you are having? <There will be 8 rounds in my game, but at the moment i'm copying and pasting round 1 over and over and changing the number of the round and picture. Isn't there a better way to go about this? I don't know how to create a loop of some sort so that the picture corresponds to the right answer. > Describe what you have tried to solve this problem <tried creating a loop for the pictures but i'm a beginner at all this so...> Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using Turing 4.1.1 |
Author: | DemonWasp [ Sun Jan 20, 2013 3:31 pm ] |
Post subject: | RE:Picture guessing game help for turing |
There are only two different parameters for each round: 1) The path to the image. 2) The string representing the correct answer. You could create two arrays of strings: one to hold image paths, the other to hold correct answers. They should have the same number of elements, and image_paths(1) should correspond to correct_answers(1), and so on. For example, image_paths(1) := "round1tiger.jpg" and correct_answers(1) := "tiger". Then, you could use a for loop to count with a variable i from 1 to (however many questions you have). Inside your for loop, load the image from image_paths(i), draw it, get the user's guess, compare it to correct_answers(i), etc. You can even use the value of i itself to count the round number. |
Author: | anchor [ Sun Jan 20, 2013 5:59 pm ] |
Post subject: | RE:Picture guessing game help for turing |
So does that mean i have to declare the strings to the answers all the way down like this: var image_paths: array 1..8 of string var correct_answers: array 1..8 of string image_paths(1) := "round1tiger.jpg" correct_answers(1) := "tiger" image_paths(2):="round2firetruck.jpg" correct_answers(2):="tiger" and etc? and how would compare the answers to the image using the strings? thank you so much for helping! |
Author: | DemonWasp [ Sun Jan 20, 2013 7:34 pm ] |
Post subject: | RE:Picture guessing game help for turing |
You can use the "init" syntax, or you can load them from a file. For the former, see: http://compsci.ca/holtsoft/doc/init.html ; for the latter, recall your lessons on file input and output (IO). Compare the answers to the user's guess in the same way that you have previously, except that instead of "tiger" or "fire_truck", you have to use correct_answers(i). |