This experiment was going to be used as the background of a small board game. I simulate a field of stars by using a simple seedable pseudorandom number generator (prng). The galaxy is divided into a coarse grid, and each frame, for each cell that is in view, I seed the prng with its coordinates. The first number I generate determines the number of stars in the current cell. I then use the prng to generate the properties for each star: its coordinates within the cell, its size and its color.
There is a lot of room for improvement;
- There is noticable 'popping' due to inaccurately determining which sectors are in view.
- Because of how the prng is seeded per sector, the galaxy is mirrored.
- I did not implement rotation for the camera.
- I think it could be a lot prettier and there is a lot of room for performance improvements.
You can control the camera by dragging or flicking. Scrolling moves the camera forwards/backwards. Double tapping triggers hyper speed.
This page is also available without text here. Do you have questions or comments? Did you find this useful? Send me an email or tweet at me: email@example.com / twitter.com/kaesve