I’m trying to generate a scrolling starfield for a game with C++ and SDL. I’m using a simple, naive algorithm that just creates a lot of white pixels on black backround. However, this “starfield” looks too unnatural – probably because of the random number generator’s poor quality (I use the rand() function).
Are there any special algorithms for generating starfields that look more or less realistic?
Thanks.
I found this useful tutorial a while ago on creating a ‘realistic’ star field. It’s not C++, but it should be easily adaptable once you get the idea.