'=========================================================================== ' Subject: DANCING TEXT IN SPACE Date: 01-25-00 (17:05) ' Author: Dieter Folger Code: PB ' Origin: folger@bnv-bamberg.de Packet: GRAPHICS.ABC '=========================================================================== '----------------------------------- ' DANCETXT for Power Basic ' Originally a QBasic program found ' in a computer magazine ' Converted and improved by D. Folger ' ---------------------------------- DEFSNG A - Z MoveText "Dancing in Space", 1, 0, 0 'Text = 17 chars max END '---------------------------------------- SUB MoveText (Txt$, blue%, green%, red%) '---------------------------------------- cg = 15 'max colors atg = 63 nrmax = 30 stp% = 4 'size of text DIM col(cg, 2), clr(2) AS INTEGER DIM s(nrmax, 1 TO 2), sw(1 TO 2), p(1 TO 4), spd(1 TO 2), lim(1 TO 2) Txt$ = LEFT$(Txt$, 21) Lim(1) = 639: Lim(2) = 479 'x/y screen dimensions sw(1) = 10 + stp% * ((LEN(Txt$) * 8) - 1) sw(2) = 10 + stp% * 18 - stp% * 3 clr(0) = blue%: clr(1) = green%: clr(2) = red% DIM TField (INT((sw(1) + 18) / 8) * 4 * (sw(2) + 1)) AS INTEGER FOR cr = 1 TO 2 p(cr) = lim(cr) / 2 - RND * 40 - sw(cr) / 2 p(cr + 2) = lim(cr) / 2 - sw(cr) / 2 FOR nr = 0 TO nrmax s(nr, cr) = RND * lim(cr) NEXT NEXT SCREEN 12 'paint a black screen first FOR i = 0 TO cg : SetRGB i, 0, 0, 0 : NEXT PRINT Txt$ FOR x = 0 TO LEN(Txt$) * 8 FOR y = 0 TO 15 IF POINT(x, y) > 0 THEN 'write bigger text LINE (50 + x * stp%, 50 + y * stp%)-STEP(stp%, stp%), POINT(x, y) - y + 1, BF END IF NEXT NEXT '------------------------------------ FOR x = 50 TO 50 + stp% * ((LEN(Txt$) * 8) - 1) FOR y = 50 + stp% * 2 TO 50 + stp% * 18 nc = POINT(x, y) IF nc > 0 THEN FOR adx = -2 TO 2 FOR ady = -2 TO 2 IF POINT(x + adx, y + ady) = 0 THEN nc = nc - cg / 25 NEXT NEXT IF nc < 0 THEN nc = 0 LINE (x - stp%, y - stp%)-STEP(stp%, stp%), nc + 1 END IF NEXT NEXT GET (45, 45 + stp% * 2)-(45 + sw(1), 45 + stp% * 2 + sw(2)), TField '------------------------------------ CLS 'Main program starts here FOR atb = 0 TO cg 'new colors FOR cr = 0 TO 2 IF clr(cr) = 0 THEN col(atb, cr) = INT(atb * INT(atg / cg)) ELSE col(atb, cr) = INT(atg - atg / (atb + 1) + 1) END IF NEXT SetRGB atb, col(atb, 0), col(atb,1), col(atb,2) NEXT RANDOMIZE TIMER DO 'Loop until keypress FOR cr = 1 TO 2 IF p(cr) < p(cr + 2) THEN spd(cr) = spd(cr) + .005 'increase for faster move ELSEIF p(cr) > p(cr + 2) THEN spd(cr) = spd(cr) - .005 END IF p(cr) = p(cr) + spd(cr) NEXT FOR nr = 0 TO nrmax 'background LINE (s(nr, 1), s(nr, 2))-STEP(nr / 6 + 1, nr / 6 + 1), 0, BF FOR cr = 1 TO 2 s(nr, cr) = s(nr, cr) - spd(cr) * nr IF s(nr, cr) < 0 THEN s(nr, cr) = lim(cr) ELSEIF s(nr, cr) > lim(cr) THEN s(nr, cr) = 0 END IF NEXT LINE (s(nr, 1), s(nr, 2))-STEP(nr / 6 + 1, nr / 6 + 1), nr / 2, BF NEXT PUT (p(1), p(2)), TField, PSET LOOP UNTIL INKEY$ <> "" END SUB '------------------------------------ SUB SetRGB (BYVAL c AS BYTE, r, g, b) '------------------------------------ LOCAL Col? ! mov ax,&h1007 ! mov bl,c ! Int &h10 ! mov Col?,bh OUT &H3C8, Col? OUT &H3C9, r OUT &H3C9, g OUT &H3C9, b END SUB