My rectangle doesn't bounce off opposite direction when reach right side of the window
Hi, I'm new to SFML and when I create my rectangle I make it go to right side of the window. When it reaches it, it should bounce off the opposite. A solution for it is when it reaches the right side, I reset the x position to (Window width - size of rectangle) and set the speed to the opposite. it works but can't I simply just change the direction without having to set the position?? cuz changing only the speed doesn't work.
Posted Jan 4, 2024, 5:57 PM UTC
14