Checking with Vectors

So I've been making a small game using C++, and I made 2 blocks (32 by 32), but I want to check collision with the main block, the collision work fine, but when using it in a for loop to check all the blocks, it will collide, but instead of stopping me, I will move slower.

Vector variable - Object is a class
std::vector<Object> block;

Moving / Checking
1
2
3
4
5
6
7
8
9
10
11
12
13
14
for (auto& x : block)
{
        if (!MainChar.isCollision(x))
	{
	     if (KeyDown(VK_RIGHT))
	     {
		   MainChar.x += 0.05;
	     }
	     else if (KeyDown(VK_LEFT))
	     {
		   MainChar.x -= 0.05;
	     }
        }
}


I want the block to stop when it collides, but not sure how to solve it. Is there a better way at doing it rather then this?
Topic archived. No new replies allowed.