We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm having a hitbox problem with the rectangle and can't get it to start back at x, instead it goes straight through the rectangle
int b = mouseY;
int c = 50;
int d = 50;
void setup() {
size(500, 500);
noStroke();
smooth();
b = mouseY;
}
void draw() {
background(200);
fill(1, 1, 1);
textSize(20);
text("score", 230, 50);
fill(255, 0, 0);
ellipse (x, y, 25, 25);
x = x +3;
fill(200, 200, 0);
rect(a, mouseY, c, d);
if (x > width) {
x = 0;
y = random(500);
} else if (
x = 0;
y = random(500);
}
}
Answers
Currently, you check
if (x > width)
-- what does that do?Also potentially of use: There are many, many past examples of working pong games in the forum:
...and several examples of bouncing ball code in the processing documentation:
Thank you!
https://forum.processing.org/two/discussion/21148/do-not-delete-your-posts