'GET.BAS by Matt Bross 'Homepage - http://www.GeoCities.Com/SoHo/7067/ 'Email - oh_bother@GeoCities.Com DEFINT A-Z SCREEN 13: CLS RANDOMIZE TIMER DIM Sprite(222) 'Make a sprite and load it into array. FOR r = 10 TO 0 STEP -1 CIRCLE (160, 100), r, r + 16 PAINT (160, 100), r + 16 NEXT GET (150, 90)-(170, 110), Sprite DIM SpriteMask(222) 'Make a mask for the sprite. A mask is the image you want with all the 'transparent parts colored as your highest palette value SCREEN 13, 255 'all other screen modes, 15. FOR ScanY = 90 TO 110 FOR ScanX = 150 TO 170 IF POINT(ScanX, ScanY) = 0 THEN PSET (ScanX, ScanY), 255 NEXT: NEXT GET (150, 90)-(170, 110), SpriteMask DIM SpriteBackground(222) 'Dim array to hold the Background 'Make random background quickly t = INT(RND * 63) FOR i = 0 TO t tile$ = tile$ + CHR$(INT(RND * 255)) NEXT CLS PRINT "Press Escape to exit" PAINT (160, 100), tile$ x = 150: y = 90: mx = 1: my = 1 'starting x & y coordinates and the amount to 'move horizontally & vertically GET (x, y)-(x + 20, y + 20), SpriteBackground 'save background DO k$ = UCASE$(INKEY$) WAIT &H3DA, 8 'WAIT for vertical retrace (the electron beam in your computer 'moniter to reach the end of its scan) PUT (x, y), SpriteBackground, PSET 'Restore Background 'Use this if you want to animate which I assume is what you are trying to do 'If not REM these out x = x + mx: y = y + my 'Move Location of Sprite IF x < 0 THEN x = 0: mx = -mx 'Set min x boundry IF x > 299 THEN x = 299: mx = -mx 'Set max x boundry IF y < 0 THEN y = 0: my = -my 'Set min y boundry IF y > 179 THEN y = 179: my = -my 'Set max y boundry GET (x, y)-(x + 20, y + 20), SpriteBackground 'GET new background PUT (x, y), SpriteMask, AND 'Erases area directly underneath sprite PUT (x, y), Sprite, OR 'Place sprite LOOP UNTIL k$ = CHR$(27) 'To understand why this works you (this migh be more than you wanted) 'must know how the Boolean operaters AND, OR, XOR work. You know that 'PSET and PRESET just dump their contents on the screen normally of in 'reverse, but AND, OR, and XOR preform bit manipulation on the binary 'equivalants palette values. You should know that in computers 0 (zero) 'means FALSE and any value that is non-zero is TRUE, and that computers work 'in binary. The way read binary is to multiply the next digit space but 'the next power of the base number, in this case (binary, or base 2), 2. 'So 11 in binary means 3, or 1 * 2 ^ 0 + 1 * 2 ^ 1 ' 'Here are some more examples: '0010 = 2 '0101 = 5 '1010 = 10 '1111 = 15 '^^^^ '|||1's column '||2's column '|4's column '8's column ' 'The operator AND, in the PUT statement, takes the binary form of the palette 'value of the background and the binary form of the palette value in the 'image and compares the each bit, or digit in a column. If both bits are 1, 'or TRUE then then output is 1. If either one or both or them are 0 then the 'output is 0. The number after all then bits have been compared is reverted 'into a decimal number and is diplayed on your screen. ' 'The OR operator, compares the two palette values and returns 1 if either or 'both values are 1. ' 'XOR, compares the two and returns 1 if if either but not both are 1 ' 'Here is a table with other Boolean operators ' Expression1 Expression2 NOT AND OR XOR EQV IMP ' ÍÍÍÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍ ÍÍÍ ÍÍÍ ÍÍÍ ÍÍÍ ÍÍÍ ÍÍÍ ' T T F T T F T T ' T F F F T T F F ' F T T F T T F T ' F F T F F F T T ' 'Back to the PUT statement 'The PSET restores the background. 'The AND changes all then palette values not the highest palette value to 0. 'The OR changes all then palette values not the lowest palette value to 'whatever color they're suposed to be.