Tip: Layer 3 backgrounds and tides disappear when you hit a message box, so plan your level around that. For example, you can add a sublevel without layer 3 at the start/midpoint, and include your message there.
Updated to use shared subroutines; also added tags and screenshots.
Note: I removed a suboffscreen call since pixi's version appears to be broken.
I replaced it with a simple offscreen check which /should/ do the same. If it doesn't I'll fix it once pixi's version is fixed.