An in development game that is heavy on perspective and animation, needed a little something extra for it’s intro and cut scenes. The solution was to create a hyperspace star field effect with individual, animated pixels.
My first attempt at the effect was to start each pixel at the screens center and randomly animate the stars outward, the result was less than satisfactory, either the range of the animation was too narrow or it was erratic.
The solution was to at initialization, create two tables, one for Y and one for y with randomly generated locations on the screen. Interestingly, to limit the resolution of the values in Pico8, we set the upper limit as a parameter of rnd(x) and subtract an amount to set the negative limit of the range, for example :
for i=1,stars do -- Generate the two co-ordinate tables used to store each stars x and y add(starx,((rnd(256)-128))) -- 256 - 128 gives us a resolution between positive 128 and negative 128 i.e. the size of our screen add(stary,((rnd(256)-128))) end