First of all, my question is not entirely specific to C # or XNA, but my code examples will use them.
I am currently trying to create a Pong clone, and I am having trouble detecting conflicts.
Each object has a specific speed (which is Vector2), Position (Vector2, also) and Speed ββ(only floating). Each time the object Update () is called, the position changes as follows:
Velocity.Normalize(); Position += Velocity * Speed;
At first, I only checked if there was currently a collision between two objects with a simple call to Intersects () from the rectangles of the objects. I quickly realized that I could not only check if the object was currently colliding with another, but rather if the object collided with the object in its path. Just checking that the two objects are currently colliding made the ball go through the oar when the speed was too high.
I tried various things to fix this problem, but none of them seemed to work. I only need a way to check if two objects collided on their way, and if they do, if they were from horizontal, vertical, or both (to change the speed of the ball accordingly).
I donβt have to immediately need a solution, maybe just the basic idea of ββhow to implement this, and I will encode it myself.
Thank you for your time.
c # xna collision-detection
Jesse emond
source share