We are about to switch to a new forum software. Until then we have removed the registration on this forum.
class Players {
float x = 0;
float y = 0;
float px = 100;
float py = 20;
float g = 0.1; // Gravity
float s = 0; // Speed
float speed = 9;
float s1 = 1; // Acceleration
boolean jumping = false;
boolean can_jump = false;
Players(float _x, float _y) {
x = _x;
y = _y;
}
void simulate() {
if (jumping) {
can_jump = false;
py-=2;
if (py<height-50) {
jumping = false;
}
}
if (py<height-20) {
if (!jumping) {
py+=2;
}
} else {
can_jump = true;
}
}
void display() {
fill(255, 0, 0);
noStroke();
arc(x, y, 100, 100, -PI, 0);
arc(x, y, 100, 10, -PI, 0);
}
void display2() {
fill(0, 255, 0);
noStroke();
arc(x, y, 100, 100, -PI, 0);
arc(x, y, 100, 10, -PI, 0);
}
/**void gravityPlayer() {
y = y + s*2; // Assigning y to itself plus the speed
s = s + g*2; // Assigning speed to itself plus the gravity
}*/
void moveP1Left() {
// Move Left
if (keyCode == LEFT) {
x = x - 3;
}
}
void moveP1Right() {
// Move Left
if (keyCode == RIGHT) {
x = x + 2;
}
}
void moveP1Jump() {
// Jump
//gravityPlayer();
/**if (y >= height - 13) {
y = height - 13;
println(y);
}*/
}
void run() {
display();
}
void run2() {
display2();
}
}
Answers
http://forum.processing.org/two/discussion/11694/how-would-i-make-the-ball-keep-moving-back-every-time-a-goal-is-scored