Star Procedures

The STAR procedure uses the MAKE command to create a star with random size and random color.

TO STAR
MAKE "G RANDOM 30 {chooses a number from 0 to 29}
SETPC RANDOM 16 {chooses a random pen color from 0 to 15}
REPEAT 5 [FD :G RT 144] {draws the star}
END

The NIGHT.SKY procedure chooses a random place on the screen and draws ONE star.

TO NIGHT.SKY
MAKE "X RANDOM 500 {chooses a random number from 0 to 499, to "wrap around"}
MAKE "Y RANDOM 282 {chooses a random number from 0 to 281, to "wrap around"}
PU
SETX :X {move to the randomly chosen spot
SETY :Y  with the pen up}
PD  {put the pen back down to draw}
STAR {draw a star}
END

Here is a procedure called MANY.STARS that will fill the sky with ONE HUNDRED stars.

TO MANY.STARS
REPEAT 100 [NIGHT.SKY] {replace the 100 with a different number for more or fewer stars}
END