We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have created a bouncing ball going back and forth (left to right). It works but I was wondering if there is a way to clean up some of the code to make it more efficient. The print statements are to help me out and the move is set to 50 so I didn't need to scroll through the console to see how it was doing. Move=5 if necessary.
diam=10 move=50 def setup(): size(500,500) background(50,50,50) startover() def startover(): global placementY, x x=width/2 placementY=int(random(10, 490)) def draw(): global x, move background(50,50,50) fill(255) ellipse(x, placementY, diam, diam) if x <=0: print("value of X: ", x) print("change over from left to right, reached ZERO") move*=-1 x=x+move elif (x < width): print("value of X: ", x) print("in between everything") x=x+move elif (x > 490): print("made it here to 500: ", x) move*=-1 x=x+move