We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Can anyone help me out with this problem?
When mouse is pressed in the top half of the window then, a circle appears. Pressing the mouse in the bottom half of the window has no effect. Any previous shape disappears when the new shape appears The shape moves down the window, two pixels at a time, until it completely disappears off the bottom of the window
I tried this code but, it doesnt work when the circle crosses the other half. :/
int x = -1000, y;
int diam = 50;
void setup() {
size(400, 400);
}
void mousePressed(){
if (y <= height/2) {
x = mouseX;
y = mouseY;
}
//else {
//}
}
void draw() {
background(0);
ellipse(x, y, diam, diam);
y++;
}
Answers
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text#latest
Is this a homework problem?
Which part that you are not able to get working -- where are you stuck?
Ah. You have a very small typo/bug.
This says "If the y value of the ball is in the upper half of the screen, update x and y to the mouse location."
That is wrong. What should it say instead?
This is the code.
Does it work? Solved?
Yes.