Has anyone written a collision detection routine that doesn’t make use of BigSprite or a good path to take to create a routine that does such? I’m hoping it will be easier to write a routine, than to reconfigure my code to use BS.
Thanks,
JuBo
This is the routine that I have started and I repeat it for each asteroid. My sprites consist of two 8x16 side by side (16x16). I first compare the X coordinates together and if they aren’t with 16, then there is no collision. If they are within 16, then I proceed to check the y coordinate. If it is also within 16, then there should be a collision. If its not within 16, then no collision takes place. Sometimes this gets me false collisions, or no collisions when there should be. I believe my use of the carry flag might not be accurate.
check4collision:
.shipast1:
GetSpriteXAddr Sprite0
ld h,a
GetSpriteYAddr Sprite0
ld l,a
GetSpriteXAddr Sprite6
ld b,a
GetSpriteYAddr Sprite6
ld c,a
ld a,h
sub b ;subtract two x coordinates
cp 16 ; are they within 16?
jr nc,.shipast2 ; no, then no collision
ld l,a
sub c ;suptract two y coordinates
cp 16 ;are they within 16?
jr nc,.shipast2 ; no, then no collision
ret ;collision detected
Any ideas of how to make this work a little better?
JuBo
Has anyone written a collision detection routine that doesn’t make use of BigSprite or a good path to take to create a routine that does such?
Thanks for the macros Andrew. They worked well with minor tweaking for my program.
JuBo
From: wsu-assem...@googlegroups.com [mailto:wsu-assem...@googlegroups.com] On Behalf Of Andrew Stanton
Sent: Sunday, May 04, 2008 10:57 PM
To: wsu-assem...@googlegroups.com