Large Star Field in Silverlight - Taste of Game, Part 2
Edit2: After posting this, I made a significant improvement on the star field... will post it tonight. In the new version there's more sense of depth not just "dots" like the one below. The star speed and brightness now is calculated better (based on square of the distance and correct view angles). See the next update tonight...will look a lot better :)
A good space game can't go without stars :)
Source code: https://nokola.com/sources/StarFieldOld.zip (the new one is in newer post)
Check out the Silverlight star field below, its intentionally large-size so that I can finally appreciate the night sky :)
Edit: I'm stupid...Brightness should be in a range 0..1 (or 0..2 or something like that)...please add / 100.0 to the Brightness (star.Brightness = Globals.Random.Next(256) / 100.0;) when you download the source. I'll update the effect when I get back home tonight.
It looks 1000 times cooler with the correct opacity...
Notice the dimmer, slow moving stars in the background. Notice the CPU usage. It's 2-3% 1080P here , if it is higher on your side, please ping me!
Also, since I made the background, you are free to use it for your purposes (credit me or not - I don't care)!
Below the Star field read a few notes on how its built.
this is the Old version of the star field.
Stars are represented with Ellipses on a Canvas. Each star has a X, Y, and Z (distance) position.
The X and Y are just normal screen coords (e.g. 0..1024 for X), depending on the control/screen size. The Z is in the range 0...1.
1 means "farthest". Z determines how fast the star moves and the size of the Ellipse.
Each star has a Brightness as well - approx 0..2. You can probably see why I chose Z to be from 0..1 now - because Z * Brightness = Star control's Opacity. It just makes things easier...
On every frame I move the ellipses - see the code.