get exact hit point in SPRCOLL

Previous topic - Next topic

djtoon

is there a way yo get the exact x,y pos of sprite colliding?
10x
:help:

backslider

Hi djtoon,

what do you mean?
You mean sth. like this?

Code (glbasic) Select

local col=false
local x;y

while true
if col=false
x=spriteX
y=spriteY
endif

if sprcoll(...) then col=true
showscreen
wend


if col is true then you should have the last position without collision in x and y...

djtoon

if the to sprites are 50x50px then where did thay hit
at 40x40 or where becose it does box coll befor pixel coll

MrTAToad

I dont think there is an efficient way - you need to examine the pixel of each sprite to determine where the overlap is - which would be slow.

The much better alternative would be to split the sprites up into smaller ones, and then you can at least detect whereabouts the collision occurred.

Moru

not to mention if the sprites overlap totally, where exactly do you count the hit? Upper left corner? Middle?