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.

Results 1 to 11 of 11

Thread: slow motion replays of previous games

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default slow motion replays of previous games

    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


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: slow motion replays of previous games

    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.

    Looking for a Java job? Visit - Java Programming Careers

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: slow motion replays of previous games

    Quote Originally Posted by WhatIsJavaAnyhow View Post
    What kind of code would allow me to do this?
    Java code?

    Seriously though, it depends on the game, on how you implement the game, etc. Basically, we have no way of telling you how to do this without you being a lot more specific. What is "one arm bandit" anyway?

  4. #4
    Junior Member
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: slow motion replays of previous games

    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

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: slow motion replays of previous games

    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)

  6. #6
    Junior Member
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: slow motion replays of previous games

    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.

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: slow motion replays of previous games

    Do you need to save the number between program runs, or just until you close the program?

  8. #8
    Junior Member
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: slow motion replays of previous games

    just until the program is closed would be great

  9. #9
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: slow motion replays of previous games

    Quote Originally Posted by WhatIsJavaAnyhow View Post
    just until the program is closed would be great
    Then just keep track of it like you would any other value: in a variable.

  10. #10
    Junior Member
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: slow motion replays of previous games

    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 ?

  11. #11
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: slow motion replays of previous games

    To answer your question, you would just store it in a List or an array. But that's not doing what I suggested.

Similar Threads

  1. Crawler is getting slow
    By manokrrish in forum Threads
    Replies: 3
    Last Post: October 18th, 2010, 10:24 AM
  2. Web Crawling is too Slow!
    By sankar236 in forum Java Networking
    Replies: 5
    Last Post: September 29th, 2010, 10:37 AM
  3. Motion Tracking Questions
    By Brt93yoda in forum Java Theory & Questions
    Replies: 6
    Last Post: August 25th, 2010, 11:19 PM
  4. new arrayList element overwrites all previous
    By twinkletoes in forum Object Oriented Programming
    Replies: 2
    Last Post: April 2nd, 2010, 08:45 AM
  5. Help! how would you code these simple games?
    By makarov in forum Java Applets
    Replies: 1
    Last Post: November 14th, 2009, 12:31 PM