Chapter 8 – Starcharts (Flashing Stars)Posted: April 13, 2013
Starmaps, display a simple starmap
Constellation Plot, entering star patterns with CHR$ CODEs
Stellar Magnitudes, plotting differing star brightnesses
Star Graphics, constructing complex shapes
Flashing Stars, two ways to make stars flash
Startrax, watch the changing shapes of the constellations over hundreds of thousands of years
Stellar Magnitude, magnitude ranges of stars.
There are two basic ways to make a star (a single pixel) flash ‘on’ and ‘off’ using the OVER command, and this can be useful in highlighting a particular point in your programs involving starmaps. You have the option of the star remaining visible or disappearing at the end of the flashing sequence.
Routine using two FOR/NEXT loops to flash a star The following one-line routine demonstrates the principles using two FOR/NEXT loops. The T loop controls the number of flashes and the ‘n’ loop acts to switch the OVER command on or off (1 or 0). It is necessary to include a brief PAUSE (PAUSE 10) to make the flashing obvious otherwise one is left with no more than a rapid flicker. It will be noted that the n loop finishes with a value of 0: in this way, the star remains visibly PLOTted at the end of the routine. If the values in the FOR/NEXT n loop are reversed thus:
…: FOR n = 0 TO 1 : …
(omitting the STEP routine as it is now superfluous), the star will disappear at the end of the routine with PLOT OVER 1 (ie unPLOT position of pixel).
1000 PRINT “flash star”: FOR f=0 TO 10: FOR n=1 TO 0 STEP -1: PLOT OVER m;200,100: PAUSE 10: NEXT n: NEXT f
Routine using a single FOR/NEXT loop to flash a star
This routine is probably easier to use and demonstrates the rather odd way in which the OVER command works. The OVER command is set to a value of 1 throughout — it unPLOTs (makes invisible) the pixel position.
However to unPLOT an unPLOTted pixel position via the next value in the FOR/NEXT loop, PLOTs the pixel back into visibility! Thus throughout the FOR/NEXT loop the OVER command becomes:
OVER 1… OVER 0… OVER 1… OVER 0… OVER 1… OVER 0…
and the star will flash in the required manner
If the FOR/NEXT loop has an effective number of steps that are uneven (2 TO 10 = 9 STEPs) then the OVER command will finish with a value of 0 and the star will be PLOTted and visible at the end of the routine — see Line 1000. If the FOR/NEXT loop has an even number of steps (1 TO 10 = 10 STEPs in Line 1001) the star will disappear with a final PLOT OVER 1 condition.
1000 PRINT “flash star-on”: FOR f=2 TO 10: PLOT OVER 1;200,100: PAUSE 10: NEXT f
1001 PRINT “flash star-off”: FOR f=1 TO 10: PLOT OVER 1;200,100: PAUSE 10: NEXT f”