Computer Science Canada Storing images in an array? |
Author: | mikey90 [ Thu Jan 25, 2007 2:56 pm ] |
Post subject: | Storing images in an array? |
Hello...I need some help. I'm creating a guessing game which display images and someone has to guess what the images is from...I will provide multiply choice answers. Could someone tell me how to store images in an array? |
Author: | DemonZ [ Thu Jan 25, 2007 3:09 pm ] | ||||||
Post subject: | Re: Storing images in an array? | ||||||
Sure its not a problem at all, all you gotta do is create a variable as an array like so:
After that there are a couple of options here, you can use a for loop to store all of the same images, or you can manually insert the pictures one by one in the different array slots like so:
But there is another way to do this, name all of your pictures under one name for example pics, then give each of them a number when you name them ex "pics 1, pics 2, pics 3, ...., and so forth" then you can code your program to sotre each individual picture like this:
This way, you are storing all the images that you want in the array using a for loop, this takes less time and is easier to work with If you have any questions just ask ill help explain to you. |
Author: | DemonZ [ Thu Jan 25, 2007 3:14 pm ] | ||
Post subject: | Re: Storing images in an array? | ||
Here is a short program I made for you that will solve your problems of storing images
|
Author: | mikey90 [ Thu Jan 25, 2007 3:23 pm ] |
Post subject: | RE:Storing images in an array? |
Alright .... just one more question. If I am giving the user a multiple choice question and I only want to display one image until the user gets it right what should I do? To give the user 3 options. |
Author: | mikey90 [ Thu Jan 25, 2007 3:23 pm ] |
Post subject: | RE:Storing images in an array? |
And thanks for helping me out |
Author: | DemonZ [ Thu Jan 25, 2007 3:43 pm ] | ||
Post subject: | Re: Storing images in an array? | ||
No problem, as for the displaying image one by one, If you have controls in your game, heres what you do: First you display the question and the choices, plus the picture, then after youll have either "get answer" that will wait until the user has typed in his letter for which answer he like to choose, you might wanna have all of your questions stored in an array and the multiple choice answers in an array as well, after that, youll have an if statement that will check if the answer is right, if it is then youll display the next picture, if it isnt, its up to you what you wanna do, have game over or repeat the question. Here a little code that might help you solve your problem:
Hope this helps |
Author: | mikey90 [ Thu Jan 25, 2007 3:56 pm ] |
Post subject: | RE:Storing images in an array? |
Could you outline how I can combine storing the pictures in the array and then displaying them with multiple choice answers? |
Author: | DemonZ [ Thu Jan 25, 2007 4:08 pm ] | ||
Post subject: | Re: Storing images in an array? | ||
here some code:
|
Author: | Clayton [ Thu Jan 25, 2007 4:17 pm ] | ||||
Post subject: | Re: Storing images in an array? | ||||
DemonZ, you basically just did his project for him... While we're at it:
Would be much better off as a record:
Check out the records and types tutorial in the Turing Walkthrough to figure out how that works ![]() |
Author: | mikey90 [ Thu Jan 25, 2007 4:25 pm ] |
Post subject: | RE:Storing images in an array? |
Im gonna try and get it to work...thanks for helping me. |
Author: | mikey90 [ Thu Jan 25, 2007 4:26 pm ] |
Post subject: | RE:Storing images in an array? |
Can I use jpeg and how do I put choices? |
Author: | DemonZ [ Fri Jan 26, 2007 10:52 am ] |
Post subject: | Re: Storing images in an array? |
your right freakman, I think i helped a bit too much, sorry but your gonna have to do the rest for yourself, just go into turing documentation to look up some things on jpgs or go onto the tutorials and learn something there, I helped u enough, sorry no more help, but your welcome |
Author: | zedx_26 [ Sun Jan 28, 2007 4:58 pm ] |
Post subject: | Re: Storing images in an array? |
I Got a question what would intstr(i) do in uploading picture command |
Author: | CodeMonkey2000 [ Sun Jan 28, 2007 5:02 pm ] |
Post subject: | RE:Storing images in an array? |
intstr converts an integer value into a string value. |