Snowflakes (BBC BASIC)

discussion of beeb/electron applications, languages, utils and educational s/w
Post Reply
User avatar
lurkio
Posts: 2069
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Snowflakes (BBC BASIC)

Post by lurkio » Thu Mar 28, 2019 12:08 am

Not seasonal, but what the heck. From the March 1985 issue of Practical Computing magazine:

Code: Select all

 10 REM "SNOWFLAKES" (c) S.DENNINGTON, Nov.1984
 20 :
 30 REM R sets size of flakes; X,Y set position on screen
 40 REM G determines central spines or not
 50 REM P sets no. of branches; F sets where they occur
 60 REM T determines inward or outward pointing branches
 70 :
 80 REM *************************************************
 90 :
110 MODE7:PRINT''"Press a key ";:*FX15
115 TIME=0:REPEATUNTILINKEY0<>-1ORTIME>1000:IFRND(-TIME)OR TRUE MODE0:VDU19,0,4,0,0,0
120 REPEAT:R=150
130 CLS
140 :
150 FORY=300TO700STEP400
160 FORX=200TO1080STEP440
170 G=RND(2)
180 FORP=1TO4:F=RND(1):T=RND(2)
190 FORangle=0TO300STEP60
200 deltaX=(SIN(RAD(angle))*R)
210 deltaY=(COS(RAD(angle))*R)
220 ON G GOTO230,240
230 MOVEX,Y:DRAWX+deltaX,Y+deltaY
240 PROCspike
250 NEXT:NEXT:NEXT:NEXT:*FX15
255 TIME=0:REPEATUNTILINKEY0<>-1ORTIME>1000:UNTILFALSE
260 END
270 :
280 :
290 DEF PROCspike
300 VX=X+(deltaX)*F:VY=Y+(deltaY)*F
310 A=((R*(1-F))*SIN(RAD(angle+60)))
320 B=((R*(1-F))*COS(RAD(angle+60)))
330 C=((R*(1-F))*SIN(RAD(angle-60)))
340 D=((R*(1-F))*COS(RAD(angle-60)))
350 ON T GOTO370,400
360 :
370 MOVEVX,VY:DRAWVX+A,VY+B
380 MOVEVX,VY:DRAWVX+C,VY+D:GOTO420
390 :
400 MOVEVX,VY:DRAWVX-A,VY-B
410 MOVEVX,VY:DRAWVX-C,VY-D
420 ENDPROC
430 :
440 DEFPROCSCREENDUM0
450 LOCALX%,Y%,Z%,M%
460 VDU2
470 VDU1,27,1,ASC"1",1,10;0;
480 FORZ%=-320TO312STEP8
490 VDU1,27,1,ASC"*",1,5,1,0,1,2;
500 FORY%=9920TO-9920STEP-640
510 M%=&5800+Y%+Z%
520 FORX%=7TO0STEP-1
530 VDU1,M%?X%,1,M%?X%
540 NEXT:NEXT:VDU1,10;0;
550 NEXT:VDU1,27,1,ASC"@";0;:VDU3
560 ENDPROC
Run the program in JSBeeb:
:idea:

EDIT: Updated for compatibility with BBC BASIC For SDL and For Windows.
Last edited by lurkio on Sat Apr 20, 2019 6:19 pm, edited 1 time in total.

User avatar
AndyF
Posts: 1229
Joined: Sat Feb 23, 2008 10:16 pm
Location: Derby
Contact:

Re: Snowflakes (BBC BASIC)

Post by AndyF » Thu Mar 28, 2019 8:43 pm

Before I even looked at the listing (when I read the topic title) I'd assumed it was going to either be random placement/removal of asterisks in Mode2 or Mode7 or perhaps a few UDG's (user defined graphics) of the same in a graphics mode.

I was very pleasantly surprised by what I found instead. =D>
Last edited by AndyF on Thu Mar 28, 2019 8:45 pm, edited 1 time in total.
Andy

* NEW * The Jetset Willy and Manic Miner community :)

Adventure games ported across to the BBC (in progress) as soon as I can find some time!

User avatar
Richard Russell
Posts: 781
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Snowflakes (BBC BASIC)

Post by Richard Russell » Thu Mar 28, 2019 10:08 pm

To get the right colours on a platform lacking a hardware palette (e.g. BBC BASIC for Windows or BBC BASIC for SDL 2.0) add a CLS (VDU 12) in line 130:

Code: Select all

  130   VDU19,0,4,0,0,0,12

Diminished
Posts: 147
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Snowflakes (BBC BASIC)

Post by Diminished » Thu Mar 28, 2019 10:33 pm

There was something like this (but different code, I believe) in one of the BEEBUGs, too.

I don't recall which one, though.

User avatar
lurkio
Posts: 2069
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: Snowflakes (BBC BASIC)

Post by lurkio » Fri Mar 29, 2019 12:41 am

AndyF wrote:
Thu Mar 28, 2019 8:43 pm
I was very pleasantly surprised by what I found
Neat, isn't it? :)

It bears a very superficial resemblance to the Biomorphs program from the April 1987 issue of The Micro User:
:idea:

Post Reply