'=========================================================================== ' Subject: MOVING SPRITE ROUTINES Date: 05-11-97 (16:42) ' Author: Cleber de Mattos Casali Code: QB, QBasic, PDS ' Origin: Landale@usa.net Packet: GRAPHICS.ABC '=========================================================================== DEFINT A-Z '$DYNAMIC ' 'QBX & QB Sprite Routines ' by LanDaLe (Cleber de Mattos Casali) ' CMC Soft. ' 'e-mail : rLanDaLe@geocities.com 'home page : www.geocities.com/siliconvalley/park/3019 ' DECLARE SUB PutSprite (sprx%, spry%, msprite%(), tela%()) DECLARE SUB PutMirror (sprx%, spry%, msprite%(), tela%()) DIM tela(1 TO 32002) AS INTEGER DIM bg(1 TO 32002) AS INTEGER DIM sprite(1 TO 602) AS INTEGER SCREEN 13 CLS COLOR 18 PRINT " This" PRINT " is a" PRINT "Sprite" GET (0, 0)-(49, 23), sprite COLOR 7 FOR cor = 1 TO 200 LINE (cor * 2 - 2, 0)-(cor * 2, 199), cor, BF NEXT GET (0, 0)-(319, 199), bg GET (0, 0)-(319, 199), tela CLS FOR x = 1 TO 319 STEP 5 PutSprite x, 130, sprite(), tela() PUT (0, 0), tela, PSET FOR restorebg = 3 TO 32002 'restore tela(restorebg) = bg(restorebg) 'the NEXT restorebg 'background NEXT x FOR x = 319 TO 1 STEP -5 PutMirror x, 130, sprite(), tela() PUT (0, 0), tela, PSET FOR restorebg = 3 TO 32002 'restore tela(restorebg) = bg(restorebg) 'the NEXT restorebg 'background NEXT x REM $STATIC SUB PutMirror (sprx%, spry%, msprite%(), tela()) ymaxtela% = tela%(2) xmaxtela& = (tela%(1) / 8) ymax% = msprite%(2) - 1 xmax% = msprite%(1) / 8 - 1 xsprindex& = 3 FOR yvaria% = spry% TO spry% + ymax% STEP 1 FOR xvaria% = sprx% + xmax% TO sprx% STEP -1 xsprindex& = xsprindex& + 1 IF yvaria% >= 0 AND yvaria% <= ymaxtela% - 1 AND xvaria% >= 0 AND xvaria% <= xmaxtela& - 1 THEN DEF SEG = VARSEG(msprite%(1)) byte% = PEEK(xsprindex&) IF byte% THEN DEF SEG = VARSEG(tela%(1)) POKE ((xmaxtela& * yvaria%) + xvaria% + 4), byte% END IF END IF NEXT xvaria% NEXT yvaria% DEF SEG END SUB SUB PutSprite (sprx%, spry%, msprite%(), tela%()) ymaxtela% = tela%(2) xmaxtela& = tela%(1) / 8 ymax% = (msprite%(2)) - 1 xmax% = (msprite%(1) / 8) - 1 xsprindex& = 3 FOR yvaria% = spry% TO spry% + ymax% STEP 1 FOR xvaria% = sprx% TO sprx% + xmax% STEP 1 xsprindex& = xsprindex& + 1 IF yvaria% >= 0 AND yvaria% <= ymaxtela% - 1 AND xvaria% >= 0 AND xvaria% <= xmaxtela& - 1 THEN DEF SEG = VARSEG(msprite%(1)) byte% = PEEK(xsprindex&) IF byte% THEN DEF SEG = VARSEG(tela%(1)) POKE ((xmaxtela& * yvaria%) + xvaria% + 4), byte% END IF END IF NEXT xvaria% NEXT yvaria% DEF SEG END SUB