Some quick enhancements to our previous moving star-field. We make the slow stars smaller than the fast stars. We let the star speed define also the star size. We do that by using the speed to set the strokeWeight(). Since the speed is a number between 1 and 5, that value is compatible with the strokeWeight(). We also make slow stars darker than fast stars. But the color values are not so compatible with the speed. The speed is a number between 1 and 5, but the colors are usually numbers between 0 and 255. So we decide to use map() to convert the 1 to 5 range into a 100 to 255 range. Stars moving 1 pixel per frame will get a gray shade of 100. Stars moving 5 pixels per frame will get a bright white color. Stars moving at speeds between 1 and 5 will get also different shades of gray.
Then we draw a triangle that represents a small space ship. We draw this triangle wherever the mouse pointer is, so we can control the position by moving the mouse. We then call the noCursor() function to hide the mouse pointer, which didn't look so good on top of our "space triangle".

Loading more stuff…

Hmm…it looks like things are taking a while to load. Try again?

Loading videos…