Wall Collision Example

0
0
Publicado 2023-06-12


This cart demonstrates basic wall collisions, animation and actor-based world objects. I hope it's useful either as something to study for ideas, or as a starting template for a platformer or overhead map-based game. I noticed a few carts reusing stuff from Jelpi, which is great -- but Jelpi might be a little complex to get started with.

See move_actor() for the important part:

The collisions work like this:

This means that as long as actors start outside of walls, they should never end up inside a wall.

There are many minor improvements that could be made -- for example, placing the actor exactly against the wall after it collides. But I've tried to keep it simple to demonstrate only the important concepts.

Note that none of this is the 'right' way to do collisions or anything else in pico-8 -- it's just the way I happen to do it.

If you have any questions about how it works, don't be shy!

EDIT: another example -- this time also with actor collisions.
Exactly the same principle, but instead of looking for solid walls, it searches through all the actors and checks for overlapping actor collision rectangles.