Log In  

Generates a random star system on load. Sometimes it generates one without a nebula at all so you may need to Cmd/Ctrl+R to reset if that happens.

Cart #55760 | 2018-08-27 | Code ▽ | Embed ▽ | No License
10

My first Pico 8 cart on the BBS. This is a cart that generates a procgen starfield with nebulae, that you can scroll through (256x256 pixel size).

The big technical achievement is the nebula. I used fractal noise with smoothing to generate the data, where every point is a 2x2 pixel area. After that I stored every row of colors as runs containing the byte length for that color and the color data. When drawing the screen I go through the runs of color, using memset to fill in the pixels which makes the dithering pretty easy, doing two rows of pixels on screen at the same time by flipping the pattern for odd numbered rows.

The really tricky part was the scrolling, particularly in the X direction, because the patterns break if the camera X coordinate is odd and not even. To fix that I draw it as if it were 1 pixel to the left with the pattern flipped, then take the last 2x2 pixel area for a run, and copy the next run's right side pattern into the right side of the 2x2 area. That fixes the one pixel offset without too much of a performance penalty. I didn't fix artifacts along the edges of the screen and instead just lazy draw a black rectangle over it.

I also used a monochrome hue ramp for this because it lets me do some other cool effects, like the blinking stars. The little one pixel stars also dim when they go behind the nebula, and dim more when behind the purple sections.

Finally I wanted to add random noise like described in the linked article, but with scrolling I couldn't really forego cls(). What I wound up doing was trying to add a few random points every frame to a table, and only keeping the last 200, removing the oldest at the start of the table first, as well as removing any that are offscreen.

All in all I'm really happy with how this turned out. :D

P#55761 2018-08-27 00:46 ( Edited 2018-08-27 09:11)

Very impressive AND visually pleasing - never thought RLE decompression would fly for realtime display!
For games that don’t need to test background tiles, the technique is great.

Btw, did you have a look at this noise function:
https://www.lexaloffle.com/bbs/?tid=31201
?

Note: if you can make it wrap (to get an infinite scrolling), you might be able to sell it to @Liquidream for his Low Mem Sky game ;)

P#55762 2018-08-27 01:40 ( Edited 2018-08-27 05:40)

Just wanted to add my praise again for this - awesome work. Plus the use of TRASEVOL_DOG's proc dither routine is very effective here, really brings the nebula to life!

Freds72 is right; I wanted something like this for the Galactic Map/Intro screen - and tried something MUCH more basic, but it looked crap in comparison! :D

(Dunno about the "sell" part tho - Hello Games ain't returned my calls yet! :P )

P#55766 2018-08-27 05:11 ( Edited 2018-08-27 09:11)

Just found this while looking for Pico-8 space generators. This is great work! It didn't get the attention it deserved. I love it.

P#61960 2019-02-16 21:42

This is awesome! Just came across it.

P#80228 2020-08-02 03:40

pretty

P#80244 2020-08-02 10:47

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-16 10:44:06 | 0.019s | Q:27