A86: Re: detecting hits


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

A86: Re: detecting hits




Hrmm, maybe I should release all the non-specific source code from my last
game...

These routines might come in handy when doing sprite or tilemap stuff:

; 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

> here is my routine to check if 2 8x8 sprites are
> hitting
> ...
> but it does not work all the time!!!
> any ideas why? i will try debugging it later but want
> to make sure the logic is right




References: