# Collision Detection Failing at faster Speed?

I am new to programming so thought I would make a Pac-Man clone to teach myself. I am doing it in C++ using SFML. Anyway, I use a bunch of collision tests. Everything works great.. but if I am going to fast then the collisions simply fail and nothing happens.

Pac-Man is moving though a factor = velocity * frametime;

I am using SFML rectangles to do the tests... eg...

sf::FloatRect.contains(pacman.getPostion);

This tests a point in space to see if it is inside the rectangle. The point being the centre of pac-man.

So yeah.. I would love to hear any ideas on this!

if ( _rectSwitch.getGlobalBounds().contains( PacMan.getPosition().x, PacMan.getPosition().y )

• Have you identified the issue? If not, you should do that first, before someone just hands you the solution, as it's a corner stone of game development to deal with stuff like this. Jul 21 '12 at 3:35
• if i knew how to stop this I wouldn't be asking Jul 21 '12 at 4:06
• I'm not telling you to stop it, I'm telling you to find out why it happens. Do some debugging. Debugging is your best friend. Try and do a step by step or frame by frame of the movement, and see what happens exactly. Jul 21 '12 at 4:07
• I don't know SFML, but there are various ways to do a step by step. If you're lucky SFML supports a function that'll run one frame, which is easiest. Alternatively, you can add a breakpoint after the game logic, so it'll freeze each frame, or if you don't want breakpoints, a blocking message box will do. Jul 21 '12 at 4:13