'=========================================================================== ' Subject: SPRITE MASKING Date: 01-19-97 (14:29) ' Author: Dave Shea Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: GRAPHICS.ABC '=========================================================================== ' >can anybody help me figure out how to make a sprite move ' >around on the background with out blotting out a square ' >behind my figure. I am also curious about HEX routines in ' >QB, if anyone could help better understand either of these ' >it would be nice. 'I'll take the first question for now. You have to use a process called '"Masking". This basically picks a color that you aren't going to show in 'your picture, and uses it as a background. Rather than describe the 'whole thing, I'll just do it. Try this out. ' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ' MASK.BAS by Dave Shea ' Released to Public Domain on January 19th, 1997. ' ' Compile: MicroSoft Quick Basic 4.5, PDS 7.1 ' ' Desc: Demonstrates the technique of masking a graphics array. ' ' (Use at your own risk) ' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= CLS : SCREEN 13 DIM Circ%(1557), MCirc%(1557) TCol = 0 'Color to be transparent '(I ALWAYS use 0) MCol = 255 'Mask color FOR a = 15 TO 1 STEP -1 CIRCLE (160, 100), a * 2, a 'Draw the circle PAINT (160, 100), a NEXT GET (130, 75)-(190, 125), Circ% 'Store it in array Circ% FOR a = 130 TO 190 FOR b = 75 TO 125 'The following commands search the circle, and 'change any pixel that's NOT the transparent 'color to the transparent color, and any pixel 'that IS the transparent color to the mask color '(This is the masking process) IF POINT(a, b) = TCol THEN PSET (a, b), MCol IF POINT(a, b) <> TCol AND POINT(a, b) <> MCol THEN PSET (a, b), TCol NEXT NEXT GET (130, 75)-(190, 125), MCirc% 'Get the new Masked Circle CLS FOR a = 1 TO 200 LINE (1, a)-(320, a), a 'Draw some lines for a background NEXT PUT (130, 75), MCirc%, AND 'Lay down the mask using AND PUT (130, 75), Circ%, XOR 'Lay down circle using XOR '(which is the default for PSET)