How to move this car?

edited January 2016 in Questions about Code

Hey I want help in moving this car without using mouseX and mouseY

The code is:

void setup() { size(300,300); background(20,40,200); }

void draw() { noStroke(); fill(60,222,240); rect(0,0,300,280);

fill(255,0,0); rect(100,220,100,50); arc(100, 270, 120,100,PI,PI3/2); arc(200,270,80,100,PI3/2,2PI); arc(150,230,100,100,PI,2PI); fill(0); arc(90,270,30,30,0,PI); arc(200,270,30,30,0,PI); fill(255); rect(127,195,20,25); rect(153,195,20,25); arc(122,220,30,45,PI,PI3/2); arc(178,220,30,45,PI3/2,2PI); fill(255,255,51); arc(62,238,20,20,PI7/8,PI*13/8); }

Tagged:

Answers

  • Edit post. Select code. Press Ctrl+ o.

  • edited January 2016 Answer ✓

    before setup()

    float xPos=0;

    in draw()

    background(0); // or background(20,40,200);  
    
    translate(xPos,0);
    
    xPos+= 0.1; // speed
    
  • Hey thanks alot for the help! I really want to add some cool animation to my object could u please tell me how to slide the car left and right? Or if there is any other cool animation I can add to it?

    Thank you!

  • edited February 2016

    ??

    I showed you how to go right.

    Now figure out left.

    try it, post your entire code

Sign In or Register to comment.