Rectangles, check.

2014 02 08

Ok, now I have covered the rectangle collisions. Now I can have them behaving as they should. I made two of the Three rectangles able to push each other and the third one just stands its ground like a wall.

I only had some issues with the rectangles jumping around the other and one time I made rectangle nr 1 move when nr 2 and nr 3 collided. Which was quite ammusing. Sorry, the code for that one is gone.

The work was pretty straight forward. The working model Changes the colliders positions by the inverted ammount of overlap in the checkcollision method in collision manager if there is an overlap. then I set the rectangles positions to the colliders positions after the call for checkcollisions in the game state’s update function. this works quite well because if there is no collision it only sets the rectangles to their current locations.


OverlapRectVsRect(). This can be improved still:

The code in Gamstate::Update() that make the two rectangles push each other:

That’s it for this saturday. tomorrow I plan on doing the same with the circles. Even though we might only need circle vs circle overlap I need to have done it at least once because in future Projects I will need to be able to have circle collisions. Plus it is my free time and I can do whatever I want. And I would love to have that done Before monday. Then I can focus all my work hours on the rectangle vs circle collisions, and the collisions should really be done by the end of next week.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s