Breakout clone collision detection

Started by
0 comments, last by BeerNutts 9 years, 6 months ago

How can I fix the mess that are the check_collision and check_brick_collision methods ? Maybe a good way to fuse them together that in addition will allow me to detect if the collision happened at the sides of a brick so I can change the xVelocity to negative too. Here is the GitHub link of the ball class that contains the said above methods.

Advertisement

Well, your "check_brick_collision()" returns true...but it doesn't tell you which brick you collided with. So, you need a way to return that a collision occurred and which brick it hit so you can remove it from the tiles.

Also, you're checking every tile, but some tiles will be destroyed, how will you handle that? Some tiles need to be marked dead or something like that.

Finally, if you want to check collisions on certain sides, the simplest method is to move the ball along the X-axis, and then check collision. If it happens, you know you hit it on the side, and can invert the x velocity. Then move along the y-axis and do the same thing.

Good luck.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

This topic is closed to new replies.

Advertisement