A86: Re: checking hits


[Prev][Next][Index][Thread]

A86: Re: checking hits




Here are a couple of routines that might work for you.  The first is to
check two 8x8 sprites, the second is to check a single point with an 8x8
sprite.

; 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

>   what was the routine that David Phillips submitted a
>   while ago that would check if two 8*8 sprites are
>   touching.
>   i  think i have something that will work but his is
>   probably better optimized




References: