'=========================================================================== ' Subject: SCREEN ART/SAVER Date: 07-08-96 (20:23) ' Author: Scott Tuttle Code: QB, QBasic, PDS ' Origin: Scott.Tuttle@newriver.net Packet: GRAPHICS.ABC '=========================================================================== 'Screen Art/Saver inspired by John Wantlands Black Hole 'but for faaster computers. RANDOMIZE TIMER DEFINT A-Z SCREEN 13 ' maxx = 320 'screen dimensions maxy = 199 'can be set for different modes FOR t = 1 TO 255 ' sets palette to shades of white b = INT(63 / 255 * t) OUT &H3C6, 255 OUT &H3C8, 256 - t OUT &H3C9, b OUT &H3C9, b OUT &H3C9, b NEXT t 'rem these out for QBASIC IF COMMAND$ <> "" THEN 'check command line num = VAL(COMMAND$) 'for number of pixels IF num < 10 THEN num = 10 END IF IF COMMAND$ = "" THEN num = 100 'to here DIM x!(num), y!(num), dx!(num), dy!(num) cx = maxx \ 2 'center coor for current screen cy = maxy \ 2 rr = 10 'diameter of black hole FOR t = 1 TO num 'init coors and speed x!(t) = RND * maxx y!(t) = RND * maxy dx!(t) = 0 dy!(t) = 0 NEXT t t1 = 1 'some constants-for speed t2 = 2 t5 = 5 t4 = 4 t6 = 6 g! = .2 'gravity factor DO FOR t = t1 TO num PRESET (x!(t), y!(t)) 'erase old pixel dx = cx - x!(t) 'compute distance dy = cy - y!(t) r = SQR(dx ^ t2 + dy ^ t2) + t1 'play with the .98 for different 'effects dx!(t) = dx!(t) * .98 + (g! / r) * dx 'accel * orbitdegradation + force dy!(t) = dy!(t) * .98 + (g! / r) * dy 'ditto x!(t) = x!(t) + dx!(t) 'calc new position y!(t) = y!(t) + dy!(t) PSET (x!(t), y!(t)), r 'draw new pixel IF r < rr THEN 'did it go into the hole? PSET (x!(t), y!(t)), 0 'erase it x!(t) = RND * (cx \ t5) 'create new pixel y!(t) = cy + RND * (cy \ t4) dy!(t) = t6 dx!(t) = t6 END IF NEXT IF RND > .95 THEN g! = RND - .05 'random the gravity-nice visual effect LOOP UNTIL INKEY$ <> "" SCREEN 0 'exit w/credits to me :) WIDTH 80 COLOR 14 PRINT "ô Â " PRINT "õcott ³uttle '96" COLOR 7 ______________________________cut here_____________________________________ 'Screen art that draws water fountains. SCREEN 13 ' you can specify the number of 'pixels on the command line 'ex: GRXFOUNT 1000 'for 1000 pixels 'rem this for qbasic IF COMMAND$ <> "" THEN 'checks to see if there's a number num = VAL(COMMAND$) 'on the command line END IF ' to here IF num = 0 THEN num = 100 'if not-its this IF num > 2000 THEN num = 2000 'limit on num DIM x(num), y(num), dx(num), dy(num) 'x-coor,y-coor,dx&dy speeds DEFINT B, T, Z 'pallette & counters RANDOMIZE TIMER g = .1 ' gravity scale1 = .627451 'scaler 1 t160 = 160 'constant int pi = 3.1415 'pi-duhh! t199 = 199 'bottom of screen constant int zero% = 0 one% = 1 two% = 2 t255 = 255 mode% = 1 DO 'color scheme bf = INT(RND * two%) rf = INT(RND * two%) gf = INT(RND * two%) LOOP UNTIL bf + gf + rf <> zero% 'no black-outs rand: 'randomizes and resets CLS dyscale = (RND * -4) - 3 'rnd dyscale dxscale = (RND * two%) + one% 'rnd dxscale da = RND * .01 'init-angle speed a = RND * pi 'init angle FOR t = one% TO num 'sets all coors and speeds PSET (x(t), y(t)), zero% y(t) = t199 x(t) = t160 dx(t) = RND * 5 - 2.5 dy(t) = -RND * 6 NEXT ' DO 'main loop FOR z = num TO one% STEP -1 'pixel loop for color FOR t = one% TO num 'loop to calc&draw LINE (t160, t199)-(x(t), y(t)), zero% 'erase old x(t) = x(t) + dx(t) 'compute new coor y(t) = y(t) + dy(t) dy(t) = dy(t) + g IF y(t) > t199 THEN 'Did pixel go through floor? x(t) = t160 'reset single pix y(t) = t199 ' with new coors IF mode% = -1 THEN dx(t) = RND * 4 - 2 dy(t) = -RND * 6 ELSE dy(t) = SIN(a) * dyscale 'and angle speeds dx(t) = COS(a) * dxscale 'constants scale speeds a = a + da 'move angle 'is it OK? reverse if not IF a > pi OR a < zero% THEN da = -da END IF END IF 'draw new pixel with color based on distance from center LINE (t160, t199)-(x(t), y(t)), scale1 * (t160 - ABS(t160 - x(t))) NEXT t IF INKEY$ <> "" THEN GOTO quit 'key check b = INT((53 / num) * z) + 10 'brightness-scaled to num pixels IF z > t255 THEN z = t255 red = rf * b green = gf * b blue = bf * b OUT &H3C6, t255 'ready to change palette OUT &H3C8, z 'color OUT &H3C9, red 'red val OUT &H3C9, green 'green val OUT &H3C9, blue 'blue val NEXT z da = da + RND * .01 'rnd the angle speeds IF da < -.1 THEN da = -.1 'see if new speed ok IF da > .1 THEN da = .1 'ditto mode% = -mode% 'another palette change DO bf = INT(RND * two%) rf = INT(RND * two%) gf = INT(RND * two%) LOOP UNTIL bf + gf + rf <> zero% dyscale = RND * -2.7 - 3.5 'rnd dyscale dxscale = RND * one% + two% 'rnd dxscale LOOP quit: SCREEN 0 WIDTH 80 COLOR 14 PRINT "ô Â " PRINT "õcott ³uttle '96" COLOR 7