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 3 of 3

Thread: Random Motion vertically

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Random Motion vertically

    Hey guys,

    I am a fairly new programmer and I am having trouble trying to figure out an algorithm or expression that will make my object move in a random motion vertically, with in certain bounds. Will show my code upon request.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Random Motion vertically

    Thread moved from Members Introductions.

    This is a vague question, as the definition of many of the terms you posted can be interpreted in different ways. That being said, see the Random class which has methods that allow one to get a random number - be it an int constrained within a particular bound or a floating point value that can be used to create a value constrained within a certain bound. If this is not what you're looking for, then I recommend elaborating on exactly what you need.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Random Motion vertically

    Yes, please show your code that creates the object and any you may have that animates it. With that, we should be able to give you some ideas how to program it to move "randomly," though as copeg said, it would be helpful to know what that means to you. An object simply jumping from the bottom to the top of the visible area and anywhere in between is not pleasing animation, but maybe that's what you're going for.