1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'Generate starry sky    [STARS.BAS]
DIM level(3) 'magnitude levels
RANDOMIZE TIMER 'so that each sky is different
SCREEN 12 '640x480 pixels
m1 = 3 'average number of mag 1 stars (default 3)
r = 8 'star number ratio per magnitude (default 8)
totalstars = m1 * (1 + r + r * r + r * r * r) '# of stars in the sky
level(1) = m1 / totalstars 'compute levels to make
level(2) = m1 * (1 + r) / totalstars '4 different magnitudes
level(3) = m1 * (1 + r + r * r) / totalstars
DO 'this is the loop that generates a new sky
CLS 'clear screen/sky
FOR i = 1 TO totalstars 'generate stars one by one
xp = RND * 640 'x position on the screen
yp = RND * 480 'y position on the screen
magtst = RND 'generate a number to determine magnitude
mag = 4 'start by assuming faintest star
IF magtst < level(3) THEN mag = 3 'then brighten if
IF magtst < level(2) THEN mag = 2 'generated random number is
IF magtst < level(1) THEN mag = 1 'within specified level
SELECT CASE mag 'now plot star according to magnitude
CASE 4
PSET (xp, yp), 8 'faintest star (try changing colour to 7?)
CASE 3
PSET (xp, yp), 15 'brightest star with a single point
CASE 2
CIRCLE (xp, yp), 1, 15 'increase app brightness by increasing size
PAINT (xp, yp), 15
CASE 1
CIRCLE (xp, yp), 1.5, 15 'brightest stars have largest area
PAINT (xp, yp), 15
END SELECT
NEXT i 'go back and plot all stars until finished
DO
a$ = INKEY$ 'wait for a keyboard input
LOOP WHILE a$ <> CHR$(27) AND a$ <> "q" 'ESC generates new sky
LOOP WHILE a$ <> "q" 'q quits program
END