06-03-2003, 06:18 AM
Going backwards for a sec from the buffer. I'm having a bit of trouble with my masking code that nathan helped me with before. I never tested his program really but I did take the general concepts and I'm sure I applied them right. I tried a few various approaches here. I've uploaded my code and files (images and .til files). Including a photoshop pallate I made. Anyway here is the code. And you can download all of it and the images here.
RNDR3.BAS
RNDR3.BAS
Code:
DEFINT A-Z
SCREEN 13
CLS
DIM sprite(65, 66 + 66) AS INTEGER
OPEN "SPRITES.TIL" FOR BINARY AS #1
length = LOF(1) - 768
FOR sprt% = 0 TO (length / 66) - 1
sprite%(0, sprt%) = 64
sprite%(1, sprt%) = 8
FOR byte% = 2 TO 33
GET #1, (sprt% * 66) + 3 + ((byte% - 2) * 2), temp%
'PRINT temp%
sprite%(byte%, sprt%) = temp%
NEXT
NEXT
'LOAD IN THE PALETTE
length = length + 1
DIM colorval AS LONG
FOR col = 245 TO 255
GET #1, length + (col * 3), R%
GET #1, length + (col * 3) + 1, G%
GET #1, length + (col * 3) + 2, b%
R% = R% AND 63
G% = G% AND 63
b% = b% AND 63
colorval& = R% + (G% * 256) + (b% * 65536)
PALETTE col, colorval&
NEXT
FOR a = 0 TO 63
PSET (a, 0), a
NEXT
' After the pallate has been loaded I'm loading in the mask.
' Both images have the same pallate composed of 10 colors. White being 10 and 0 being black I believe. Well no in the photoshop pallate it was I don't no how it's rearanged now.
'here I'm loading the mask
DIM mask(65, 66 + 66) AS INTEGER
OPEN "MASK2.TIL" FOR BINARY AS #2
length = LOF(2) - 768
FOR sprt% = 0 TO (length / 66) - 1
mask%(0, sprt%) = 64
mask%(1, sprt%) = 8
FOR byte% = 2 TO 33
GET #2, (sprt% * 66) + 3 + ((byte% - 2) * 2), temp%
'PRINT temp%
mask%(byte%, sprt%) = temp%
NEXT
NEXT
PAINT (100, 100), 1
'*********** Draws the sprite
FOR z = 0 TO 1
FOR drawx = 0 TO 21
IF z = 0 THEN
a = 0
b = 2
ELSE
a = 3
b = 5
END IF
FOR drawy = a TO b
PUT (drawx * 8, drawy * 8), sprite(0, spritenum), PSET
spritenum = spritenum + 1
NEXT drawy
NEXT drawx
NEXT z
'************ Draws the mask over it
FOR z = 0 TO 1
FOR drawx = 0 TO 21
IF z = 0 THEN
a = 0 + 6
b = 2 + 6
ELSE
a = 3 + 6
b = 5 + 6
END IF
FOR drawy = a TO b
PUT (drawx * 8, drawy * 8), mask(0, masknum), XOR
masknum = masknum + 1
NEXT drawy
NEXT drawx
NEXT z
'*********** Just for show like nathan did in his example
spritenum = 0
FOR z = 0 TO 1
FOR drawx = 0 TO 21
IF z = 0 THEN
a = 0 + 12
b = 2 + 12
ELSE
a = 3 + 12
b = 5 + 12
END IF
FOR drawy = a TO b
PUT (drawx * 8, drawy * 8), sprite(0, spritenum), PSET
spritenum = spritenum + 1
NEXT drawy
NEXT drawx
NEXT z
'************
masknum = 0
FOR z = 0 TO 1
FOR drawx = 0 TO 21
IF z = 0 THEN
a = 0
b = 2
ELSE
a = 3
b = 5
END IF
FOR drawy = a TO b
PUT (drawx * 8, drawy * 8), mask(0, masknum), XOR
masknum = masknum + 1
NEXT drawy
NEXT drawx
NEXT z
DO: LOOP UNTIL INKEY$ <> ""
CLOSE #1, #2
·····································LINEAR INC·····································
Ã-----------------------------------------------------------------------O
From Problem to Solution - We take the shortest distance
Ã-----------------------------------------------------------------------O
From Problem to Solution - We take the shortest distance