# Slope handling in a tile-based platformer

I'm trying to implement slopes in my 2D tile-based platformer made in GameMaker Studio 1.4.

I'm done with the normal solid block tiles, they work like charm, but slopes are even harder than I expected.

There are many problems with what I already tried. At some point, I was somewhat OK with it, but somewhat OK is not enough, it must be perfect.

So let's talk about uphill and let's assume our slope is going right.

So I need to check if we are in a slope. When we are, I need to calculate how much we are in the slope. Since it's a 45 degree slope for now, we should move the character upwards the same amount of pixels as we are in the slope. That looks and works fine for most of the cases.

• But let's face some of the issues: If there are not wall tiles (black ones in the picture) then the player may fall down between two slope tiles.
• Going down doesn't work in my current implementation, it works if I ignore, how much I am in the tile (but then, it snaps to the
slope even if I don't touch it, but I'm really in the slope tile),
really visible, when I am at the left-most part of the slope (snaps
to the bottom). Also sometimes it just positions kinda badly... Look at the Grounded variable state.

• If I ignore the intrusion amount (so it snaps into the tile), then I'm still not good yet, as reaching the bottom of the slope may move me out sideways. Applying the x velocity may make me leave the slope tile before applying the y position and since I left the tile, there won't be y position applying. My character will be above ground for a while depends on x velocity and gravity. At higher x velocity, the player may left the slope tile more than one pixels above the ground.

In overall, all the solutions I tried were imperfect. Most of the times, it work, but there are those situations where it becomes unreliable, especially at higher speeds. I think I will go until 8 pixels / frames speed with a very few of the objects. I wonder how specific games did it? I tried to learn from games like Castlevania - Dawn of Sorrow, since I got an editor for it and I experimented with slopes. To make the slopes work perfectly, there must be an solid block below the slopes at the intersections, or the player will fall between them. I wouldn't mind this that much. Worst case scenario, I would mark some tiles with some special flag below the slopes.

Screenshots from Symphony of the Night's hidden debug mode room:

This is how Dawn of Sorrow (not) handles slopes:

So I'm a bit confused / puzzled about the situation.

• It looks mostly like you just need to increase gravity. If you look at the castlevania gif, the character falls really fast. That or slow the player down. – CobaltHex Dec 4 '17 at 16:05