r/sfml•
FranTheFar

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.

https://preview.redd.it/2cttxeompgac1.png?width=1078&format=png&auto=webp&s=4cf596798130723fececea16b33eb14de093ede0

Posted Jan 4, 2024, 5:57 PM UTC

14
Loading comments…