Log In  

A starfield effect, inspired by the old Windows screensaver, though the style is more in line with Star Trek. Use up and down to increase and decrease speed, and press X to show stats.

I used nucleartide's Pico-8 snippets, specifically vec3 and pline(), to do the 3D projection. I was encouraged by reinvdwoerd's Perspective Lines and used his cartridge to figure out how to use pline().

To really get immersed, shout "increase speed to [warp number]!" as you hold the up key or "all stop!" as you slow down to zero.

Cart #starfield-0 | 2019-02-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#61959 2019-02-16 22:46

:: a2

Great stuff!

P#61980 2019-02-17 13:59
:: a2

@PicoLate I'd love to do something similar to this in my game. Would you mind relicensing this code under something more permissive, like the MIT license that nucleartide/pico-snippets is under?

P#61982 2019-02-17 14:24

@a2 You're free to use it however you want, no credit necessary, and I promise I won't sue! I just selected Pico-8's default licensing option, figuring it's better than nothing at all. I don't know how to license it with the MIT license, other than hosting it on Github.

Besides, I don't think my code is original enough to warrant it; plenty of people have done 3D starfields before, and nucleartide's stuff is doing the heavy lifting here.

Also, if you wait a day or two, I'm working on a tweet-length cart that does a 3D starfield with much fewer characters, possibly making it easier to drop into whatever you're working on.

P#62009 2019-02-18 02:27
:: a2

@PicoLate Sure, that makes sense. All good :) Looking forward to your tweet-length cart :)

P#62025 2019-02-18 08:54

@PicoLate In addition to my original praise for this effect on Twitter - I did have a suggestion for your consideration that may improve the effect even more?

What if the stars start out, briefly, at color 1 (dark blue)?
I think it may make their appearance from the depths of space even smoother than they already are.

Anyway - just a thought! ;-)

P#62030 2019-02-18 14:54

@Liquidream I think I tried starting the colors out at blue, but rejected it for some reason. Maybe it didn't look as nice as I expected, but I'll try it again. You'll notice that I made a mistake with the colors in this starfield. The stars are supposed to go from dark grey to grey to white, but at some point I got them mixed up and they go from dark grey to white to grey! Fixing this should make the stars feel smoother.

P#62039 2019-02-18 17:03

@PicoLate Fair enough.
(And didn't notice the bug - but yeah, that should help too!)

P#62041 2019-02-18 17:08

@PicoLate I love the effect, nice job!

P#62044 2019-02-18 20:29

I really want to use this routine in a game I'm working on, but it's quite token-heavy. Does anyone have any ideas for optimising/trimming it?

P#92559 2021-05-25 16:54

@timeandspace You're in luck. I made a post with smaller versions of starfields here. You'll be interested in the mini starfield or, if you're really pressed for space, the tweet starfield.

P#92562 2021-05-25 18:11

Excellent! Thanks for the heads-up.

P#92563 2021-05-25 18:52

@timeandspace Also, note that the tweet starfield has visual errors because a star's z-coordinate can sometimes be zero! I did that to save a couple characters.

Therefore you should either go with the mini starfield snippet, or use this altered version of the tweet snippet:

function _init()
for i=-32,n do
function _draw()
for i=1,n do
if q.z>-1.2then
function p(x,y,z)
return -x/z*n+n,-y/z*n+n

I changed "if q.z>-1then" to "if q.z>-1.2then", ensuring that when 1 is added to the z-coordinate of a star q, the z-coordinate will still always be less than zero, or else the star's position is reset.

Of course, the mini starfield is heavily commented and much more amenable to alterations so that you can fit it into your game how you like, so you probably ought to look at that one anyway :).

P#92566 2021-05-25 19:50

I'm going to use the multi-colour routine. It's still smaller than the original routine on this page, and it looks too awesome not to use!

P#92567 2021-05-25 19:53

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-07-25 16:26:32 | 0.061s | Q:36