A83: Re: Hit Detection
[Prev][Next][Index][Thread]
A83: Re: Hit Detection
These assume your sprites are 8x8. They could probably be better optimized.
However they do work perfectly:
; bc = (x1,y1), de = (x2,y2)
; returns: no carry = collision
CheckCollision:
ld a,d
add a,7
cp b
ret c
ld a,b
add a,7
cp d
ret c
ld a,e
add a,7
cp c
ret c
ld a,c
add a,7
cp e
ret
; in: bc = point, de = coords
; returns: no carry = collision
CheckPoint:
ld a,d
add a,7
cp b
ret c
ld a,e
add a,7
cp c
ret c
ld a,b
cp d
ret c
ld a,c
cp e
ret
>
> Does anybody have a good routine for hit detection? If not maybe a
tutorial that i could read. Thanks that would be great.
>
_____________________________________________
NetZero - Defenders of the Free World
Click here for FREE Internet Access and Email
http://www.netzero.net/download/index.html
References: