Platformer Physics Tutorial (Summary)
A lengthy tutorial on how to program smooth, 2D vectorial platformer physics from scratch.
You can read the whole article here: https://github.com/Pere001/2d-platformer-tutorial-2023.

But here’s a very simplified summary:

It gets quite complex, but basically this is the core of the article. Once we have our collision function in place, we use an iterative approach to move very close to the edge of the walls in the direction we are moving in.
Then it’s a matter of determining which edge we would collide against first.


And we use the edge normal to update the speed’s direction. Upon collision, we can either bounce or slide, which is a choice we’ll make based on our velocity.
I also show how to easily add little tweaks and polish to the mechanics by also using an iterative approach. In this case, we break down each step into smaller steps and do a collision check on each of them to find out at what point the entity disconnects from the ground, so we can try to stick it back on it by pushing back down, also with the help of iteration.

It’s not the fastest of methods, but it’s a good way to get started and learn the fundamentals you will need to program movement mechanics in a game with vectorial terrain.