Re: A85: Sprite Routines
[Prev][Next][Index][Thread]
Re: A85: Sprite Routines
>
>If anyone wants the library to attempt to port the routines to the 85, I'd
>be glad to send the most recent version to them. There is a new Collision
>routine which has so far been untested. So, I have no idea if the 82 will
>even crash or not using that routine. Collision will detect a SOLID
>collision between two shrunken bounding boxes of any two (they can even be
>different sized) sprites. However, remember it's untested and so it might
>have a bug or two in it.
>
speaking of collision routines, here is the one i used in solomon's
key. its real fast, and works with sprites (bounding boxes) of the
same size.
;Square Sprite collision routine.
;Input:
; a has the size of the length of the square edge (a = 8 for 8 pixel
sprite)
; bc has (x,y) of top left of first sprite
; de has (x,y) of top left of second sprite
;Output:
; carry flag set if no collision occurs
; carry flag reset on collision
;Destroys:
; a
SpriteCollision:
dec a
add a,b
cp d
ret c ;no collision
sub b ;reg a again has edge length
add a,d
cp b
ret c ;no collision
sub d
add a,c
cp e
ret c ;no collision
sub c
add a,e
cp c
ret c ;no collision
or a ;clear the carry, collision!
ret
-mike pearce
Follow-Ups:
References: