I made this bit of code for creating a parallax effect for side-scrolling games. It uses three layers of infinitely repeating maps. I've set it up so that all the code is in a self-contained section that can be copied and pasted below your own code, with just an initialise, update and draw function needing to be called from the respective functions in your game.
More complete instructions can be found in the header of the code.
I hope somebody finds it useful!
Nifty. Might be worth noting that since your star field is simple shapes, you can probably draw most of them using built-in methods like circfill() or rectfill() or even just pset() to set the color of pixels.
Not only can it then be really random, I'd think it would be faster to render than any sprite or map since it doesn't have to fetch that resource at all.
Check out my RGB shooter cart, it has a random pixel star background. Not much variance in color/size as your map version but should be enough in there to work with. However, I just took that star code from some other cart, so I don't claim the code behind it.
Ahh that's a great tip about not using sprites. To be honest I wanted to make a parallax effect that could be reused for lots of different games, not just space, so sprites need to be used for that. However for a space game, yeah definitely the methods you suggest are better.
[Please log in to post a comment]