Hi
I'm currently making a one arm bandit for an assignment. One of the features that it needs to have is a button that lets you view a slow motion replay of the previous game.
What kind of code would allow me to do this?
thanks
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi
I'm currently making a one arm bandit for an assignment. One of the features that it needs to have is a button that lets you view a slow motion replay of the previous game.
What kind of code would allow me to do this?
thanks
Hello and welcome to the Java Programming Forums.
I guess you will need to keep track of everything that happened in the game, then recall this information to simulate a replay.
You could use a timer to execute the movements at a slower pace.
Have you started work on this yet? I would be interested in seeing your code.
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Thanks for a the replies!
First, a one arm bandit is basically a fruit machine, where there are three reels with 8 shapes on each. Different combinations win different amounts of money etc.
It would be fairly straight forward to make a slower timer, but to remember exactly how each reel spun in the previous game- that i'm not so sure of.
I have used Case statments to generate the results at random.
Any ideas?
Thanks
My first idea would be to use the Random class to generate the same random results each time. If you want to play a different game, use a different seed. To play the same game, use the same seed.
Random (Java Platform SE 6)
ahh that is a very good idea kevin
Now i just need to find a way to record each number that is generated from the previous game, so I can then repeat this sequence. Any ideas on this?
I currently have a system print out of all the numbers which apear as the game is in progress.
Do you need to save the number between program runs, or just until you close the program?
just until the program is closed would be great
so I have:
spin1 = random.nextInt(4);
System.out.println(spin1 + "");
replay = spin1;
switch (spin1){
case 0:
btnSpinPictures.setIcon(iconPic1);
spin1=0;
counter++;
break;
case 1:
btnSpinPictures.setIcon(iconPic2);
spin1=1;
counter++;
break;
case 2:
btnSpinPictures.setIcon(iconPic3);
spin1=2;
counter++;
break;
case 3:
btnSpinPictures.setIcon(iconPic4);
spin1=3;
counter++;
break;
}
if(counter==10){
stopTimer();
}
The system print is giving me, say, this:
0
1
2
1
3
2
1
How would I record that in the form of 0121321 ?
To answer your question, you would just store it in a List or an array. But that's not doing what I suggested.