Hi, I’m currently trying to make a program that draws a line moving across the screen, if it reaches the edge ideally it’ll move in the opposite direction. When I run the program it seems to be stuck on the far left side, but when I println the variables it increases and decreases appropriately. Can someone help? Here’s what I have so far:
Sorry if I wasn’t clear, that’s not quite what I’m trying to do. I’m trying to make it so that when the line touches the edge of the screen, it starts moving in the opposite direction. So when it touches the right side of the canvas it then moves to the left side and vice versa
draw in itself loops automatically, that’s one of the main ideas of processing.
In fact, something that happens in a for-loop cannot be seen as an animation since the canvas is not updated throughout but only at the end of draw(). So a for-loop adds everything to the internal canvas and only once at the end of draw () the internal canvas gets displayed on screen.
Ahh that answers a lot of questions, I didn’t know that. Thanks everyone for the help, much appreciated guess the answer was a lot simpler than I thought it’d be lol
as Chrisir said adding c to position and check when reaching both borders
The command for this is an if-clause; it checks if a value c is higher than width (or equal or smaller…)