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

Thread: Objects - Moving Shapes in JAVA HELP PLEASE!

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    1
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Objects - Moving Shapes in JAVA HELP PLEASE!

    Hey guys,

    I need some help... Basically I got a few shapes in java and made it into a car, I now need to move all the shapes together across the screen. How would I do this?

    Here is my code, I can move one shape at a time but not all of them together.

    public class Vehicle
    {
    private Circle wL;
    private Circle wR;
    private Rectangle b1;
    private Rectangle b2;


    /**
    * Constructor for objects of class Vehicle.
    */
    public Vehicle()
    {

    }

    /**
    * Draw your vehicle.
    */
    public void draw()
    {
    wL = new Circle ();
    wL.makeVisible();
    wL.changeSize(60);
    wL.moveVertical(130);
    wL.moveHorizontal(100);

    wR = new Circle ();
    wR.makeVisible();
    wR.changeSize(60);
    wR.moveVertical(130);
    wR.moveHorizontal(220);

    body1 = new Rectangle ();
    b1.makeVisible();
    b1.changeSize(190, 60);
    b1.moveVertical(80);
    b1.moveHorizontal(70);

    body2 = new Rectangle ();
    b2.makeVisible();
    b2.changeSize(100, 30);
    b2.moveVertical(50);
    b2.moveHorizontal(95);







    }

    /**
    * Move your vehicle a little to the right.
    */

    public void moveRight()
    {




    wheelR.slowMoveHorizontal(80);
    wheelL.slowMoveHorizontal(80);


    }

    /**
    * Move your vehicle a little to the left.
    */
    public void moveLeft()
    {


    }
    }


    the section I put in red doesn't seem to work there but if i move it up to under the b2 part it works

    using .slowMoveHorizontal(); under the yellow part I can get the shapes moving but one after the other. How do I correct this?

    Thanks for reading


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Objects - Moving Shapes in JAVA HELP PLEASE!

    Please use code tags and not colour highlights when posting code.

    Iterater over all the shapes and adjust their x co-ord.
    Improving the world one idiot at a time!

Similar Threads

  1. collision detection moving objects
    By nichodiaz in forum What's Wrong With My Code?
    Replies: 12
    Last Post: June 14th, 2013, 02:21 AM
  2. Moving Two Objects at Once
    By BellarmineSeattle in forum Java Theory & Questions
    Replies: 2
    Last Post: January 23rd, 2013, 04:44 PM
  3. Java TV Board Game/Grid + Moving objects
    By Massaslayer in forum Java Theory & Questions
    Replies: 6
    Last Post: December 13th, 2011, 08:03 AM
  4. Combining Shapes + Text
    By aussiemcgr in forum Java Theory & Questions
    Replies: 5
    Last Post: February 17th, 2011, 10:15 AM
  5. How I can create those shapes with Java?
    By Learner in forum AWT / Java Swing
    Replies: 3
    Last Post: November 18th, 2010, 02:10 AM

Tags for this Thread