Snowfall in BASIC
We are now in the winter season and it’s been snowing here in Maine, so I thought it might be fun to put together a little BASIC program that simulates falling snow on a tree.
I wrote this program in standard Atari BASIC and it is (pun intended) pretty basic. It uses graphics mode 2, which is just 40x20 pixels with four colors. This gives things a nice, blocky, 8-bit feel.
Simple PLOT and DRAWTO commands are used to draw the tree. The falling snow is tracked using a couple arrays and drawn using the PLOT command. The LOCATE command is used to check if snow touches something else. If it does then it is left at its last position and a snow one starts at a random position at the top.
Believe it or not, I don’t know Atari BASIC as well as I used to so I used my copy of Atari BASIC XL Edition to help refresh my memory on how the COLOR and SETCOLOR commands worked. Luckily I remembered how LOCATE worked because I surprisingly didn’t find any info in the book about it, but perhaps I didn’t look hard enough.
Here’s the program:
10 GRAPHICS 3
15 PRINT “SNOWFALL FROM GOTO 10”
16 PRINT “WWW.GOTO10RETRO.COM”
19 REM DRAW THE TREE
20 COLOR 2
30 PLOT 20,5:TX=20
40 FOR TY=1 TO 10
50 PLOT TX-TY,TY+5:DRAWTO TX+TY,TY+5
60 NEXT TY
69 REM DRAW TREE TRUNK
70 SETCOLOR 2,2,0:COLOR 3
80 PLOT 18,16
90 DRAWTO 22,16
100 DRAWTO 22,18
110 DRAWTO 18,18
120 DRAWTO 18,16
124 REM DRAW FALLING SNOW
125 SETCOLOR 0,0,15
130 DIM X(5),Y(5)
131 FOR I=1 TO 5:X(I)=RND(0)*39:Y(I)=0:NEXT I
150 FOR S=1 TO 5
155 LOCATE X(S),Y(S),SCOL
156 IF SCOL<>0 THEN GOTO 175
160 IF Y(S)>0 THEN COLOR 4:PLOT X(S),Y(S)-1
170 COLOR 1:PLOT X(S),Y(S):Y(S)=Y(S)+1:IF Y(S)<20 THEN GOTO 180
175 Y(S)=0:X(S)=RND(0)*39
180 NEXT S
200 GOTO 150You can copy/paste this code to easily run it in your favorite emulator. I like Atari800MacX.
I’d love to see some conversions of this to other versions of BASIC. There are also lots of improvements you could do.
Perhaps you might want to try to crunch the entire thing down so it is 10 lines or less? Or maybe use one of the higher resolution graphics modes that have more colors. You could add sound or music.
If you come up with something cool, please share it in the comments!
Here’s a longer video that gives the snow more chance to accumulate:




