Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
Simple Map Borders
Print
Pages: [
1
]
Author
Topic: Simple Map Borders (Read 2469 times)
0 Members and 1 Guest are viewing this topic.
enderboy768
Newbie
Posts: 9
Simple Map Borders
«
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!
Logged
fallahn
Hero Member
Posts: 507
Buns.
Re: Simple Map Borders
«
Reply #1 on:
May 14, 2017, 02:59:07 pm »
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
Logged
Twitter
Super Video Golf
Tiled Map loader
Carlos Augusto Br Cpp
Newbie
Posts: 40
Programming is life
Re: Simple Map Borders
«
Reply #2 on:
June 01, 2017, 05:41:25 pm »
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...
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
Simple Map Borders
anything