A86: Re: collisions


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

A86: Re: collisions




I use this routine in my game to check the collision of two sprites.  The
only thing it destroys is AF, and it's fairly fast, too, so it might come in
handy.  It's a perfect bounding box for 8x8 sprites, you should (I think) be
able to change the numbers for different sizes of sprites.

; 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


> ok.  say i had two sprites drawn to the screen.  one of them was permanant
> the other the user could move around.  how would i tell if the user's
sprite
> hit the other sprite?
>
> -=-=1414=-=-
>
> ~one of these days I'm gonna put a game out~
>
>



Follow-Ups: References: