10-08-2004, 09:15 AM
In my game, I want it so that when the player's spear/sword/whatever hits an npc, the npc disappears. unfortunately my pixel collision is a bit buggy... this is what i have.
would this be returning false collisions? Because i'm sure that sometimes i'm not hitting the sprite yet he dies.
Code:
function pixelcol (tileseg1, tileoff1, tile1x, tile1y, tileseg2, tileoff2, tile2x, tile2y)
for y = 0 to tile.height
for x = 0 to tile.wid
if pointclone (tileseg1, tileoff1, x,y) <> 0 then
x2 = tile1x + x - tile2x
y2 = tile1y + y - tile2y
if pointclone(tileseg2, tileoff2, x2,y2) <> 0 then
pixelcol= 1
exit sub
endif
endif
next x,y
end function
FUNCTION pointclone (segment, offset, x, y)
DEF SEG = segment
pointclone = PEEK(x + y * tile.wid + offset)
END FUNCTION
would this be returning false collisions? Because i'm sure that sometimes i'm not hitting the sprite yet he dies.
Jumping Jahoolipers!