We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have been working on code for so many hours straight, I'm starting to loose my mind.
Trying to get the circle appear from right to left, as opposed from left to right. It's a simple answer, but I cannot figure it out right now.
// this time, we get the circle to "warp" back to the left side
PImage bg;
// here, the number 50 is half of the circle's diameter
float x = 500;
//--------------------------------------------------------
void setup() {
size(852, 480);
noFill();
stroke(255); // white
strokeWeight(2);
bg = loadImage("bg.jpg");
}
//--------------------------------------------------------
void draw() {
background(bg); // background picure
ellipse(x, 150, 100, 100);
// by adding the circle's radius to the width of the window,
// we allows it to "leave" the screen on the right side
// and warp only when it's no longer visible
if ( x > width + 50 ) {
x = x - 2;
}
else {
// move the circle back to the left side of the window
x = 450;
}
}
Answers
Your if is wrong! You want to check the Ball against the left side, not the right side
I know, the if statement is wrong, I don't know how to fix it. There's a flip of a negative or something, I can't figure it out.
@NoName please correct the format of the code above