
-----------------------------------
brownni
Tue Jun 05, 2012 4:22 pm

Final Project Time!
-----------------------------------
Hey guys well its final project time and i need some help.
I do not know how to make an array filled with images, that i can roll and randomly pick one.
I am making a slot machine game and need all of the help i can get! 
Thanks Brownni

-----------------------------------
Aange10
Tue Jun 05, 2012 4:34 pm

RE:Final Project Time!
-----------------------------------
That's interesting.

-----------------------------------
mirhagk
Tue Jun 05, 2012 4:58 pm

RE:Final Project Time!
-----------------------------------
create an array, use a for loop to load in the images, and then use a random number generator modded by the size of the array to get a random image. (if you want it to roll you should just have them move really quickly past the screen, and then have them roll for a bit more once the user clicks the button)

-----------------------------------
Raknarg
Tue Jun 05, 2012 8:17 pm

RE:Final Project Time!
-----------------------------------
The interesting thing about images is that they're integers, so you can just create an array of integers and assign pictures to them. Have you ever tried working with pictures before?

-----------------------------------
brownni
Wed Jun 06, 2012 12:24 pm

Re: Final Project Time!
-----------------------------------
I have worked with arrays but loading in images in the spot of integers i am competely lost. 

And thanks for the quick replys guys  :o

-----------------------------------
Raknarg
Wed Jun 06, 2012 12:46 pm

RE:Final Project Time!
-----------------------------------
http://compsci.ca/v3/viewtopic.php?t=191

-----------------------------------
brownni
Wed Jun 06, 2012 1:05 pm

Re: Final Project Time!
-----------------------------------
I have not taken a look at that link yet but, I was thinking what if i made a string array. and within the string array it was the name of the picture files, so that when it gets pulled out i can then set a new image icon to the index and it would point to that image.... if you understand what i am saying ??
Example
----------
lblWhatEver[5].setIcon(new imageIcon(picArray[index]); ???
soo. The label is out of an array of 5, and which ever string gets picked than set that name to the pic that i want>

-----------------------------------
brownni
Wed Jun 06, 2012 1:06 pm

Re: Final Project Time!
-----------------------------------
OH MY IM SORRY!! I JUST REALIZED I DIDNT SAY IT WAS JAVA :) I took grade 11 this year after i did the grade 10 course :D

-----------------------------------
mirhagk
Wed Jun 06, 2012 2:24 pm

RE:Final Project Time!
-----------------------------------
no that's actually @Raknarg's fault. This is the Java section, we should assume it's java. You can do a similar thing in java though, just have an array of imageIcon's. My Java is rusty but I believe it'd be like:
[code]
ImageIcon[] imageIcons=new ImageIcon[arraySize];
[/code]
assuming ImageIcon is the class your using and arraySize is the number of pictures there are. Then do something like:
[code]
for(int i=0;i