Close

Stars

A project log for Merlin

68000 Retro Super Computer

matthew-pearceMatthew Pearce 07/07/2021 at 08:460 Comments

Using the new random function and simple points plotting, it's easy to create an animated starfield in Basic.

10 PRINT "SHOWING STARS. PRESS ANY KEY TO STOP"                                 
15 DIM X(20): DIM Y(20)                                                         
20 FOR I=0 TO 19                                                                
25 X(I)=RND(I)*512                                                              
26 Y(I)=RND(I)*512                                                              
30 NEXT I                                                                       
35 REM DRAW STARS                                                               
40 CLS $0: CLR                                                                  
42 POINT 0,0,$0,4,1                                                             
45 FOR I=0 TO 19                                                                
50 POINT X(I),Y(I),$FFFFFF,1,0                                                  
51 Y(I)=Y(I)+RND(I)*50                                                          
52 IF Y(I) > 512 THEN Y(I) = 0                                                  
60 NEXT I                                                                       
70 REM SWAP BUFFER                                                              
75 GDSWAP                                                                       
80 GET A$                                                                       
85 IF A$="" THEN GOTO 40                                                        
90 PRINT "DONE"                                                                 
100 END     

Discussions