# High Speed Collision Detecting in Super M

## Recommended Posts

So I'm working on my latest project, Platformisis, which is a game development suite written by me. Platformisis deals with the creation of 2D platform games or 2D games in general. Anyways, I'm currently in the process of creating a game called Bluejay's Quest which is a game about a bird that belongs to Mario but gets separated from him. The goal of the game is to find Mario whom the bird is a pet of.

Currently dealing with collision detection theory in the game. I recently (well, last year to be exact) learned how to do collision detection in 2D platform games. I set up a box for the object that the main character would collide with and place points on each corner of the main character. I'm using four points on each corner indented about 4 pixels in on the x-axis. So my character can move fast - like 4 pixels per frame but if I want him to move really fast, like 8 pixels per frame or even higher how do I handle this type of collision without more than one point being inside of the other sprite's bounding box? What I mean is that in order to detect a collision with a wall on the left one or both points on the left would need to be inside the wall's bounding box. However, is it possible that points on both side could be inside of the wall's box and then it would look like my character is standing by two walls. How do I deal with this issue?

##### Share on other sites

To me it sounds like you should implement a different collision strategy. The points strategy you have so far works well if you are using a tile grid, and you limit speeds so that objects can not *tunnel* (a link on tunneling) through one another. But, since you want to have faster speeds, you need a new strategy that can cope with tunneling easily.

First I would try representing your box not as four points, but as a full 2D area, implicitly defined by a point + width and height (or some similar format). This will prevent the possibility of your box points from straddling a skinny wall.

Next, you need to figure out a way to find the time of impact, of when your box will collide between two game ticks. Implementing time of impact solvers is typically quite difficult. Your best bet would be to try a binary search algorithm. Here is a link: http://digitalrune.github.io/DigitalRune-Documentation/html/138fc8fe-c536-40e0-af6b-0fb7e8eb9623.htm#Bisection

##### Share on other sites
Instead of using points against bounding boxes for collision, use bounding boxes (AABB axis-aligned bounding box) or other shapes like spheres to represent ALL things in your game that has collision.   I.e. test the bounding box of your character against the bounding box of the wall. Detection tests between them should be relatively easy as is moving the object back to the collision point.   Using boxes and spheres, you should get less tunnelling type problems than points, but it’s still possible at higher speeds.  In which case there are more complicated methods to do this as suggested or just up the number of steps you do movement/collision steps per render frame.  E.g. so you would end up with 2 lots of 4 pixels movements, per frame to make up a 8 pixel movement etc.

## Create an account

Register a new account

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633416
• Total Posts
3011780
• ### Who's Online (See full list)

There are no registered users currently online

×