Pico-8 Bach Inventions Effects ~ Day 2: Stormy Seas (Patreon)
Content
Hi everyone!
Today's Bach Invention portrait features stormy seas, with lightning and angry clouds! And all these effects are actually super simple!
Let's follow the draw order and start with the stormy seas! That's somewhat obvious but it's only one rather big sprite drawn again and again!
The dark-grey color is palette-swapped with black so as to create an outline of sorts.
We use cos() and sin() to move each 64x32 sprite on the screen. The angle used for these functions depends on the time, the original x coordinate of the sprite and the original y coordinate. It is defined like this:
<code>local xx=flr(x/64)
local yy=flr(y/8)
local a=-t*3+yy/16+(xx+(yy%2)*0.5)/3
</code>
Draw a big dark-blue rectangle in the background to hide the gaps between the sprites and we have our wave effect!
Next comes the lighting effect! No more than a few lines drawn from randomized coordinates to randomized coordinates!
It goes like this:
<code>-- x should be defined beforehand
local lx,ly=x,0
for y=0,96,8 do
local nx=x+rnd(32)-16
local ny=y+rnd(8)-4
line(lx,ly,nx,ny,7)
lx,ly=nx,ny
end
</code>
But that will only draw a random broken line on the screen, we need to make it thicker! For that, we just have to draw every line some few more times with incremental offsets, in yellow before drawing the white, and before that, in black on the sides. Here's a still of what the final result looks like:
Finally come the clouds! There again, very simple stuff, we just draw a line of circles of varying heights and radius. Both depend on combinations of trigonometric functions used with an angle depending on the time and the x coordinate.
The line of circles is drawn twice, once slightly bigger and lighter with the color 13 (indigo) and over that, slightly smaller and higher and darker with the color 1 (dark-blue), to make the cloud convincing!
And that's pretty much it! I'm very happy with this one!
Once again, my generous 5$+ supporters can find the source files for this animated portrait over there!
Thank you for reading, see you again tomorrow!
Take care!
TRASEVOL_DOG