How to make object jump

edited October 2015 in How To...

I am making a little game using processing for one my little projects and need help trying to make the ball jump upon key or mouse press. The closest I got was making the ball move up in its y-axis upon mouse click but can't figure out how to make it come down by its own accord. Any help on this will be appreciated!

Also, how do I make it so that when the ball comes in contact with the red obstacle, the ball will be reset back to its initial starting point?

Code:

int x = -55;

void setup() { size(1900,700); background(121,234,255); }

void draw() { background(121,234,255);

stroke(0,255,0); fill(0, 255, 0); rect(0, 490, 1900, 10);

stroke(188, 161, 72); fill(188, 161, 72); rect(0, 500, 1900, 700);

stroke(255, 0, 0); fill(255, 0, 0); rect(500, 410, 30, 80);

stroke(255, 0, 0); fill(255, 0, 0); rect(1350, 410, 30, 80);

stroke(245, 190, 7); fill(245, 190, 7); ellipse(x, 462, 55, 55); x = x + 2;

}

Thank you!

Answers

Sign In or Register to comment.