💾 Archived View for gem.lizsugar.me › 2022 › 11 › 14 › collision-detection.gmi captured on 2024-05-10 at 10:48:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-03-21)
-=-=-=-=-=-=-
// 2022-11-14, 1 min read, #programming #pico-8 #game design
I would say that collision detection has absolutely been my greatest enemy during any of my game development. I am not very mathematically inclined, especially when you start adding in acceleration and friction.
Thankfully PICO-8 comes with a demo set of games to showcase various concepts, a couple of which include different forms of collision detection. Both `jelpi.p8` and `collide.p8` contain collision detection. The first is a side scrolling platformer, and the second is a top-down movement demo. The code for `collide.p8` was easier for me to understand at the time I chose it, so that's what I went with and tweaked it for my side-view platformer (it does not scroll). I am rethinking this, and perhaps I should re-review the code in `jelpi.p8`. It might be a lot more manageable to modify that into what I need for my game.
PICO-8 does something that I really appreciate, and something that I don't think was available in PAlib (GBA/NDS): Sprite Flags. Being able to mark some arbitrary flags on a sprite, place those sprites as tiles on the map, and then check the flags of any given tile at runtime is so handy. Different Sprite flags to define walls and floors, ladders, even spawn points for players and enemies makes things a lot easier than I expected it to. I remember specifically in my mobile app dev android game that the easiest solution for me to implement at the time was hard code screen coordinates to form the walls for each screen. Granted, that was primarily a demo project meant solely to survive a presentation, with no intent to be developed further.
Aside: I am greatly struggling to remember how we implemented anything in that game. How did we draw the graphics to the screen? How did we handle player input? I don't remember any of that and it's doing my head in a little.. I should be kind to myself, that was 14 years ago
The current thing I'm really struggling with is _ladders_, which is part of collision detection.
The player character bounces violently at the top of the ladder while also getting stuck in the floor at the bottom. This is true on the ladders that end at the very bottom of the screen too _sigh_
I'm playing with a couple of different ideas for how to solve this.
---