Oh … I have no problem with the code as such. I’m guessing I’m misunderstanding the canvas(and maybe not only it) rendering system.
I’ll try to explain:
Assuming canvas size 100x100 (px)
Since the canvas width starts from the left (start, 0 px) and goes to the right (to the end of the width, 100 px)
therefore, if the x coordinate is greater than the width of the canvas, then the ball extends beyond the right edge (past the 100px mark).
if the x coordinate is less than the width of the canvas, then the ball goes beyond the left edge (passes the 0 px width mark)
Hope this is correct …
Then, since the height starts at the bottom (start, 0 px) and goes up (to the end of the height, 100 px)
therefore, if the y coordinate is greater than the height of the canvas, then the ball extends past the top edge (past the 100px height mark).
if the y coordinate is less than the canvas height, then the ball goes past the bottom edge (passes the 0 px height mark)
But the lesson says the opposite …
My best guess at the moment is that the calculation of the height in the canvas (everywhere?) Goes from top to bottom. But I’m not sure and I wanted clarification on this score.
Thanks for your time and have a nice day.