To use this starfield generator in your own app, use
starfield.js and its dependencies
starfield.js provides a function called
getStars, which takes the following parameters:
xposition of the upper-left corner of the current viewport in the gameworld's coordinates.
yposition of the same.
worldWidth, the width of the current viewport in the gameworld's coordinates.
worldHeight, the height.
and returns an array of
Star objects, which specify the positions of the stars in the gameworld's coordinates as well as their brightnesses, which range from
The remaining files in the project handle rendering to the canvas, browser events, and fullscreen. You can leave them out if your project already handles those tasks.
Here's a write-up about how the starfield generator works: