2D: Traversing Slopes and Uneven Ground?

Started by
4 comments, last by Mokda 16 years, 1 month ago
Hi all, I have a platform game that uses a deformable landscape (ala Worms) and i've just got the collision, scrolling, movement, animation, etc done to the point where i'm thinking "OMG! I almost have a basic game here!"... Then I realised I don't really have a way for the player to move over any irregular landscape (they may have deformed by firing rockets at it, etc) in a smooth manner and it turned out the same was true for climbing sloped surfaces... The player can still jump around on this "broken" ground but walking around on the pitted surface of sharp pixel edges causes the player to constantly come to a halt as he clashes with pixels jutting out of the uneven surface or his bounding box's edge clashes with the semi-circular slope of a Worms-a-like post-explosion crater. The current player-vs-enviroment collision check uses a bounding box slightly smaller than the players character and loops through the pixels that lie on the edges of that box every frame of animation. If the uint in the collision map array at that point (player position + current pixel being checked position) is not = to the "clear space" value then the game checks the uints value against the collision responces and pefroms that collision responce (Bring players movement in that direction to a halt, propel the player, kill the player, injur the player, teleport the player, put player in stealth mode, etc, etc). So my current fear is my collision checks are too crude to handle this. I could REALLY use some tips on ways to handle 2D movement over uneven ground that can be deformed by the player at runtime and/or up slopes... (If it makes a difference this is using C# and XNA) Thanks in advance
Advertisement
(Note, tbe below is just a guess based on playing Worms, it might not be actually how they do things).

It looks like they divide the movement into two halves - terrain following and collision detection. Terrain following determines how a walking worm will move across a jagged surface, and seems to be done on a single-pixel basis. Stepping left just checks the collumn of pixels left of the current position, and sees how much the worm would have to step up or down to still be on empty ground. If the vertical step is less than some threshold (about 2 or 3 pixels I think) then the worm can walk there.

The collision detection on top of this is just like you've already described - checking a box around the worm to see if anything is blocked. If it is then the movement isn't allowed (which stops the player crawling into single-pixel gaps).

Hope that helps.
Thanks OrangyTang that makes sense! :¬D and it's so simple.... but not as simple as I feel for not thinking of it myself :¬(

Again, many thanks :¬)
that's sounds like how Lemmings handles the same problem.

If it makes you feel any better, this is NOT an easy problem to deal with and one that i never fully handled myself. I was oworking with polygonal collision geometries instead of pixels, so it's a little different, but still... good luck to ya!
www.72dpiarmy.com

Theres a section on 2D scrollers with just what youre looking for. I wish he'd rekindle that tutorial series
That section at www.72dpiarmy.com is ...missing(?). I would like to read that where ever it is!

This topic is closed to new replies.

Advertisement