SFML community forums
Help => Graphics => Topic started by: enderboy768 on May 14, 2017, 02:00:18 pm
-
How do I create like an invisible wall at each side of my window so any moving object can not pass through it? I tried setting the speed to 0 or multiplying it by -1 if the object reach the side, but if I press the arrow keys several times it would still go through it. Sorry if this sounds like a noob question. Thank you in advance! ;D
-
Have a look at this post which explains some basic collision testing. There's some sample code at the bottom:
http://trederia.blogspot.co.uk/2016/02/2d-physics-101-pong.html
-
You can make an if statement to check if the actual position of the object that you want to collide with walls, plus its own size, are greater or equal to the window side that you want...
I hope that it helps...
much love...