Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Simple Map Borders  (Read 1864 times)

0 Members and 1 Guest are viewing this topic.

enderboy768

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
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!  ;D

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
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

Carlos Augusto Br Cpp

  • Newbie
  • *
  • Posts: 40
  • Programming is life
    • View Profile
    • Email
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...