Shadow Techniques
Shadow Techniques
OVERVIEW
This cart is a bit of a demo of a few shadow methods I've given some thought to. The first two techniques work best at 60fps, but the final technique I think is suitable at any speed.
UPDATE
The original cart had an issue where the 'peekpoke merge' technique could not draw starting at odd numbered X coordinates. This has been fixed (but made things a bit more complicated)
METHODS
1 ONOFF SPRITE:
This method uses a solid shadow sprite that cycles between onoff every frame
2 ALTERNATE PATTERNED SPRITE:
This method uses two sprites with an alternating pattern that is cycled every frame
3 PEEKPOKE MERGE:
This is what I really wanted to get to :) This method uses a defined palette of darker colours. Each PICO-8 colour is given a darker alternative. For some, that is full black, but for 8 (red), it is given dark purple (2).
The shadow sprite is read in from PICO-8's memory and every pixel that is not black is considered shadow, and black is ignored.
The draw coordinates for the shadow are read from memory in the graphic area, the existing colour values are determined and are replaced with their darker version wherever there is shadow pixel in the sprite
The new darker pixels are poked back into memory
CONTROLS
O: Cycle shadow method
X: Cycle background
Down: Toggle background scrolling