'=========================================================================== ' 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) ' Allocate memory 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 SELECT CASE ScreenNo% ' Determine the Width and Height of the screen ' According to the resolution. CASE 1 XReso% = 320 YReso% = 200 CASE 2 XReso% = 640 YReso% = 200 CASE 7 XReso% = 320 YReso% = 200 CASE 8 XReso% = 640 YReso% = 200 CASE 9 XReso% = 640 YReso% = 350 CASE 10 XReso% = 640 YReso% = 350 CASE 11 XReso% = 640 YReso% = 480 CASE 12 XReso% = 640 YReso% = 480 CASE 13 XReso% = 320 YReso% = 200 CASE ELSE PRINT "Unsupported graphics mode: "; ScreenNo% END END SELECT Dots% = 100 ' Number of dot on the screen at all time DIM XPos%(Dots%) ' Allocate memory for the X-axis locations DIM YPos%(Dots%) ' Allocate memory for the Y-axis locations RANDOMIZE TIMER ' The magic trick for random numbers. FOR Init% = 1 TO Dots% ' Initialize the starting X-axis and Y-axis ' locations of the 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 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 ' Now check to see if ' 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 FOR delay% = 1 TO 2000: NEXT delay% ' A *very* simple ' delay routine. 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 LOOP WHILE INKEY$ = "" ' And loop until a key ' is pressed.