Skip to main content
GameDev.net gamedev.net
🔒 Locked

Collision detection for lemming/TIM-like game

Started by randomZ Feb 13, 2005 at 1:58 PM 0 replies 2.5k views
Original Post
randomZ
randomZ
Two friends and me made a game for a 72hour competition back in december. The game is kind of a mixture of Lemmings and The Incredible Machine: You need to help the main character reach the level exit by placing bricks and jump markers in the level; all of this in 2d. (You can find the current version of the game at my website.) However, the collision detection is very buggy. Let me illustrate the problem: Currently, the whole world is made up of bounding rectangles (axis-aligned). Collision is checked by checking whether two of these rectangles overlap. However, we also need to know what side of the brick/enemy the player collided with to determine the reaction (turn around, die etc.). E.g., there are bricks who are harmless if touched from above but lethal from any other direction. To check from what direction the collision occured, the overlapping rectangle is examined. If its width is greater than its height, the collision occured from above or below. If its height is greater than its width, the collision occured from the left or right. Obviously, this last part introduces bugs, e.g. when the falling velocity (or *any* velocity, for that matter) is high. So I'm looking for a better way to accomplish this. Some things I already came up with: - Make everything pixel-based and move the player only one pixel at a time. Con: I'd need to rewrite most of the game, since right now it's all floating-point ^^ - Do intersection tests from the player's corners moving with the player's velocity. E.g.:

player - moves to the bottom-right
 ---- 
|    |\ 
|    | \ 
 ----   \ 
 \    \  \ 
  \    \  \ 
   \    \  \ 
    \ ----  \ 
     |    |  \ 
     |    |   \ 
      ----     \ 
      brick
Since the ray that hits the brick first hits it from above, the hit is from above. But what if the object is small enough that none of the rays hits it? Has anyone got any other suggestions? I'm sure many people have done jump'n'runs before :)
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
oliii
oliii
the jnrdev site gives a complete example of 2D jump and run techniques, especially concerning collsion detection. The test is still only dealing with intersections.

I have some sort of tutorial on 2D vector collision detection.

very similar to it

Metanet

Hope that answers your questions.
Everything is better with Metal.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.