Pico-8 Bach Inventions Effects ~ Day 9: Starry Sky (Patreon)
Content
Hi everyone!
Today's portrait features a stary night sky! That's what we are looking at today!
And I guess this is the "lazy" post of this week, because today you're just getting a few sprites, a code snippet and then some remarks about those. I hope that's cool!
cls(0)
srand(666)
for y=0,15 do
for x=0,15 do
local x=x*8+rnd(8)
local y=y*8+rnd(8)
local s=rnd(50)>1 and (7+rnd(7)) or (14+rnd(2))
spr(s,x,y)
end
end
</code>
This snippet is to put in the start of the _draw() function and it draws a randomly generated starry night sky!
Essentially, this snippet draws random star sprites, on a grid but each with a random offset, and there's a smaller chance that it uses the two last star sprites rather than the others.
Drawing things on a grid but with random offsets is a cool simple technique that will make it so the sprites look randomly placed but also evenly spread out. Simply drawing a bunch of stars at totally random positions would have looked much more irregular, messy and, in this case, not very good.
You might think we could just draw points, rather than sprites. That's true but it would look less good. Even though some of my sprites a literally colored points, the others are not and that makes the whole set more interesting. In fact, I would recommend using sprites rather than points for any kind of particle effects. (if you have sprite space to spare anyway) It will simply look more interesting!
If you don't have much Pico-8 CPU to spare but you're not using the (whole) map, you should use the map! That will fix the sprites to the grid, but I promise it will still look quite good! You can either hand-tile the map or use code to cover a part of the map with random star tiles. Then display it with the 'map()' function!
Finally, the colors I used are in my opinion the best to draw stars, but you can add in one color like blue or red or even green if you want, but only one. From what I tried in the past, adding multiple colors completely breaks the harmony.
That's it for today! Do ask any questions you might have!
As usual, the downloads for this portrait are available to my 5$+ supporters over there!
Thank you for reading!
Take care!
TRASEVOL_DOG