GLBasic forum

Main forum => GLBasic - en => Topic started by: djtoon on 2010-Sep-06

Title: get exact hit point in SPRCOLL
Post by: djtoon on 2010-Sep-06
is there a way yo get the exact x,y pos of sprite colliding?
10x
:help:
Title: Re: get exact hit point in SPRCOLL
Post by: backslider on 2010-Sep-06
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...
Title: Re: get exact hit point in SPRCOLL
Post by: djtoon on 2010-Sep-06
if the to sprites are 50x50px then where did thay hit
at 40x40 or where becose it does box coll befor pixel coll
Title: Re: get exact hit point in SPRCOLL
Post by: MrTAToad on 2010-Sep-06
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.
Title: Re: get exact hit point in SPRCOLL
Post by: Moru on 2010-Sep-06
not to mention if the sprites overlap totally, where exactly do you count the hit? Upper left corner? Middle?