Workbench

Directionally Aware Collision Detection in Pico-8

Notes on detecting which side of the hit box a sprite has hit for the Pico-8 fantasy console

I've been tinkering with Pico-8 lately and I find myself wanting to be able to detect collisions between a sprite and a map tile, and change the sprite direction accordingly (basically the same "bouncing ball" behavior you see in a lot of intro lessons, where a ball is moving on a diagonal and reverses X direction if it hits the side of the screen, or Y direction if it hits the top or bottom.

Basic Collision Detection

There are some good Pico-8 collision detection how-tos out there:

...but these only return a boolean indicating a collision state; there's no way to determine which side the collision has happened on.

Determining Directionality

Their function uses slopes to compare the angle of the sprite to the nearest corner of the hitbox, where the nearest corner is determined by which geometric quadrant the sprite is moving towards.

TeamworkCast implements a function that determines whether an object is colliding vertically or horizontally as part of their Breakout clone series on YouTube, in video #7[1].

There are some subtleties involved in actually integrating this function as well, and those are covered in video #8.[2]


  1. Video: https://www.youtube.com/watch?v=AGblHq-ZamI, Code: https://pastebin.com/dCRQsXTJ ↩︎

  2. Video: https://www.youtube.com/watch?v=fBi6vPcFmJ4 ↩︎


Sat Jan 03 2026 19:00:00 GMT-0500 (Eastern Standard Time)