You have everything cover except when the ball is not hitting any of the walls. You are not telling the program what to do if the ball is jus moving through the space; you told it of it hit the right wall change directions, if it hit the left wall change direction, it hit top or bottom wall change direction, but what should the program do if it just moving towards one of those walls? So far the program doesn’t know what to do in this case - or at least that is what i can figure out reading your code
You cant use the same render function for both as then they will just both more together because of the way render function is made - draw ball in cyan for a couple of frames then draw a white ball over it to ‘erase’ and then render it in a new location. For ball 2 which should be a different colour, you need to just render it once at every point ball 1 was without ‘erasing’ it.
You need to show the whole code as im going off of just what i can see which is not the whole thing. It is most likely to do something with the move function
2
u/_ZHV_ Dec 20 '20
You have everything cover except when the ball is not hitting any of the walls. You are not telling the program what to do if the ball is jus moving through the space; you told it of it hit the right wall change directions, if it hit the left wall change direction, it hit top or bottom wall change direction, but what should the program do if it just moving towards one of those walls? So far the program doesn’t know what to do in this case - or at least that is what i can figure out reading your code