Slopes in 2D Platformer

Posted by Carlosrdz1 on Game Development See other posts from Game Development or by Carlosrdz1
Published on 2012-06-19T22:42:04Z Indexed on 2012/06/20 3:24 UTC
Read the original article Hit count: 216

Filed under:
|
|

I'm dealing with Slopes in a 2D platformer game I'm developing in XNA Game Studio. I was really tired of trying without success, until I found this post: 45° Slopes in a Tile based 2D platformer, and I solved part of the problem with the bummzack answer.

Now I'm dealing with 2 more problems:

1) Inverted slopes:

The post says:

If you're only dealing with 45 degree angles, then it gets even simpler:

y1 = y + (x1 - x)

If the slope is the other way round, it's:

y1 = y + (v - (x1 - x))

My question is, what if I'm dealing with slopes with less than 45 degree angles? Does y1 = y + (v - (x1 - x)) work?

2) Going down the slope:

I can't find a better way to handle the "going down through the slope" situation, considering that my player can accelerate its velocity.

Edit: I was about to post a image but I guess I need to have more reputation he he he... What I'm trying to say with "going down" is like walking towards the opposite direction, assuming that if you are walking to the right, you are incrementing your Y position because you are climbing the slope, but if you are walking to the left, you are decrementing your Y position.

© Game Development or respective owner

Related posts about XNA

Related posts about 2d