'=========================================================================== ' Subject: SNOW FALL SIMULATION FOR BASEC Date: 01-20-99 (07:26) ' Author: The ABC Programmer Code: BEC ' Origin: voxel@edmc.net Packet: BASEC.ABC '=========================================================================== 'Snowfall.bas for BASEC v0.15 by William Yu 'Requires GRAPHICS.LIB from Multi-Media Library (BEC-MM.ZIP). '=========================================================================== ' Subject: SNOW FALLING Date: 01-03-96 (03:01) ' Author: Stephan van Loendersloot Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: GRAPHICS.ABC '=========================================================================== 'Code for snow falling dwarreling down. 'Released to Public Domain by Stephan van Loendersloot DIM ColArray%(3) AS INTEGER ' Allocate memory DIM SCREENNO% AS INTEGER DIM XRESO% AS INTEGER DIM YRESO% AS INTEGER DIM DOTS% AS INTEGER DIM INIT% AS INTEGER DIM TAKEDOT% AS INTEGER DIM XRANDOM% AS INTEGER DIM DELAY% AS INTEGER DIM COL% AS INTEGER DIM T! AS SINGLE DIM Delay! AS SINGLE Delay! = 0.05 ' Universal delay ColArray%(1) = 15 ' Colors that can be used by the ColArray%(2) = 8 ' snow (dots) to some sort of 3D ColArray%(3) = 7 ' effect like they're moving front/back ScreenNo% = 12 ' Screen mode XReso% = 640 YReso% = 480 Dots% = 100 ' Number of dot on the screen at all time DIM XPos%(100) AS INTEGER ' Allocate memory for the X-axis locations DIM YPos%(100) AS INTEGER ' Allocate memory for the Y-axis locations RANDOMIZE TIMER ' The magic trick for random numbers. FOR Init% = 1 TO Dots% YPos%(Init%) = INT(RND * YReso%) + 1 ' Random number between 1-YReso% XPos%(Init%) = INT(RND * XReso%) + 1 ' Random number between 1-XReso% NEXT Init% SCREEN ScreenNo% ' Set screen mode DO T! = TIMER FOR TakeDot% = 1 TO Dots% ' Draw as many pixels as Dots% PSET (XPos%(TakeDot%), YPos%(TakeDot%)), 0 ' Erase previously ' set dot. Of course ' In the beginning ' there's no dot. YPos%(TakeDot%) = YPos%(TakeDot%) + INT(RND * 5) ' Determine by a ' random number ' between 0-5 how ' fast a dot should ' dwarrel. XRandom% = INT(RND * 6) + 1 ' Determine by a ' random number ' between 1-6 how ' if a dot should go ' left or right and ' how far IF XRandom% > 3 THEN XRandom% = 3 - XRandom% ' If a dot dwarrels ' over 3 to the right ' make it go to the ' left 3-random no. XPos%(TakeDot%) = XPos%(TakeDot%) + XRandom% ' New position of the ' dot. IF YPos%(TakeDot%) > YReso% - 1 THEN ' the dot has fallen ' off the screen ;-) YPos%(TakeDot%) = 1 ' If so, then put it ' on top again, XPos%(TakeDot%) = INT(RND * XReso%) + 1 ' with a new random ' position on the x-axis. END IF Col% = ColArray%(INT(RND * 3) + 1) ' Determine the ' color of the dot PSET (XPos%(TakeDot%), YPos%(TakeDot%)), Col% ' And write the dot ' on the screen NEXT TakeDot% ' take the next dot WHILE TIMER-T! < Delay! ' Universal delay WEND LOOP UNTIL INKEY$ <> "" END