Here are the steps for a Tiled Smooth platformer, (probably the most popular method of all.)
Read More Here: The Guide to Implementing 2D PlatformersAssuming that there are no slopes and one-way platforms, the algorithm is straightforward:
1) Decompose movement into X and Y axes, step one at a time. If you’re planning on implementing slopes afterwards, step X first, then Y. Otherwise, the order shouldn’t matter much. Then, for each axis:
2) Get the coordinate of the forward-facing edge, e.g. : If walking left, the x coordinate of left of bounding box. If walking right, x coordinate of right side. If up, y coordinate of top, etc.
3) Figure which lines of tiles the bounding box intersects with – this will give you a minimum and maximum tile value on the OPPOSITE axis. For example, if we’re walking left, perhaps the player intersects with horizontal rows 32, 33 and 34 (that is, tiles with y = 32 * TS, y = 33 * TS, and y = 34 * TS, where TS = tile size).
4) Scan along those lines of tiles and towards the direction of movement until you find the closest static obstacle. Then loop through every moving obstacle, and determine which is the closest obstacle that is actually on your path.
5) The total movement of the player along that direction is then the minimum between the distance to closest obstacle, and the amount that you wanted to move in the first place.
6) Move player to the new position. With this new position, step the other coordinate, if still not done.
(Rodrigo Monteiro)
How do you guys go about making your platformers, would you follow these similar steps too or do something else?
As the title suggests lets talk 2d platformers!
Any code examples will be immensely appreciated \(^_^)/