'=========================================================================== ' Subject: SIMPLE ANIMATION IN PB Date: 07-11-95 (22:01) ' Author: Rolf Genster Code: PB ' Origin: Rolf@ice.prima.ruhr.de Packet: GRAPHICS.ABC '=========================================================================== 'Program Name : ANIMATE.BAS 'Description : Simple animation in PowerBASIC DEFINT A-Z DIM Array1( 2000 ) DIM Array2( 2000 ) DIM a$( 40 ) RESTORE Ship FOR i = 1 TO 20 READ a$( i ) NEXT i apage = 1 vpage = 0 dsp = 0 hs = 3 'Horz Size vs = 2 'Vert Size ho = 4 'Horz Offset vo = 4 'Vert Offset SCREEN 9,, apage, vpage GOSUB ShipUpMk hs = 3: vs = 2: ho = 4: vo = 4 GOSUB ShipDnMk d = 1 x1 = 280 Idle: k$ = UCASE$( INKEY$ ): IF k$ = CHR$( 27 ) THEN SYSTEM GOSUB movchar SWAP apage, vpage SCREEN,, apage, vpage FOR Dly = 1 TO 500: NEXT Dly IF vos > 275 THEN d = 0 IF vos < 3 THEN d = 1 GOTO Idle END ShipUpMk: FOR j = 1 TO 20 FOR i = 1 TO LEN( a$( j )) t$ = MID$( a$( j ), i, 1 ) ' K 0 black ' B 1 Blue ' G 2 Green ' C 3 Cyan ' R 4 Red ' M 5 Magenta ' N 6 Brown ' W 7 White ' A 8 Gray ' b 9 Light Blue ' g 10 Light Green ' c 11 Light Cyan ' r 12 Light Red ' m 13 Light Magenta ' y 14 Yellow ' w 15 Bright White fg = INSTR( "BGCRMBWAbgcrmyw", t$ ) LINE( 0 + ho, 0 + vo ) - ( hs + ho, vs + vo ), fg, bf ho = ho + 2 NEXT i ho = 4: n = n + 1: vo = vo + 2 NEXT j x1 = 0: y1 = 0: x2 = 74: y2 = 50 GET( x1, y1 ) - ( x2, y2 ), Array1 RETURN ShipDnMk: RESTORE Ship FOR j = 20 TO 1 STEP - 1 FOR i = 1 TO LEN( a$( j )) t$ = MID$( a$( j ), i, 1 ) fg = INSTR( "BGCRMBWAbgcrmyw", t$ ) LINE( 0 + ho, 0 + vo ) - ( hs + ho, vs + vo ), fg, bf ho = ho + 2 NEXT i ho = 4: n = n + 1: vo = vo + 2 NEXT j x1 = 0: y1 = 0: x2 = 74: y2 = 50 GET( x1, y1 ) - ( x2, y2 ), Array2 RETURN MovChar: CLS IF d = 1 THEN vos = vos + 3 PUT( x1, y1 + vos ), Array2 ELSE vos = vos - 3 PUT( x1, y1 + vos ), Array1 END IF Dsp = 1 RETURN Ship: DATA " bb " DATA " BBBB " DATA " BBBB " DATA " BB " DATA " AABBAA " DATA " AGGCCGGA " DATA " AGGGCCGGGA " DATA " AGGGGGGGGGGA " DATA " AGGGGGGGGGGA " DATA " y AGGGGGGGGGGGGA y " DATA " ACA AADGGGGGGGGGGRAA ACA " DATA " ACA AAGGGRGGGmmGGGRGGGAA ACA " DATA " ACGAAAGGGGGRGGmmmmGGRGGGGGAAAGCA " DATA " ACGGGGGGGGGGRGmmmmGRGGGGGGGGGGCA " DATA " GGGGGGGGGGGGRGmGGmGRGGGGGGGGGGGG " DATA " AACGGGGGGGRGGGGGGGGGGRGGGGGGGCA " DATA " ACCGGGRRRRRRRRRRRRRRGGGCCA " DATA " AGGRRRRRAAAAARRRRRRGGA " DATA " ARRRRAAA AAARRRRA " DATA " RRyR RyRR "