The basic idea is to shoot a ray from the player's origin until it hits a wall, and then use the distance from the player to the wall to calculate how high that portion of the wall should be drawn.
A little extra magic figures out where along the wall the ray hits, giving us a UV coordinate to plug into blit and copy a portion of a buffer of wall textures in place of just a solid colour.
This basic example shows how to produce a scanline-rendered ray cast pseudo 3D environment from a 2D map.
Much of the theory was gleaned from: https://lodev.org/cgtutor/raycasting.html and also used in 32blit's RayCaster demo - https://github.com/32blit/32blit-sdk/tree/master/examples/raycaster
The basic idea is to shoot a ray from the player's origin until it hits a wall, and then use the distance from the player to the wall to calculate how high that portion of the wall should be drawn.
A little extra magic figures out where along the wall the ray hits, giving us a UV coordinate to plug into
blit
and copy a portion of a buffer of wall textures in place of just a solid colour.Falls back to untextured solid colours. Upload the "gadgetoid-raycaster.16bpp" asset to your PicoSystem to see textured mode: https://github.com/pimoroni/picosystem/blob/main/assets/gadgetoid-raycaster.16bpp
TODO: