[A83] Re: My Own Lame Sprite Collision Routine.....
[Prev][Next][Index][Thread]
[A83] Re: My Own Lame Sprite Collision Routine.....
I usually make a routine in basic first...
a=x2-x1
a=a+7
if a<0 then ret
if a>=15 then ret
a=y2-y1
a=a+7
if a<0 then ret
if a>=15 then ret
When you have the routine in basic, you then translate it to ASM:
;x1=c
;x2=e
ld a,e
sub c
add a,7
cp 15
ret nc
Note that the "if a<0..." line was taken out... this is because
negative numbers are >127.
Repeat that miniroutine for Y values...
Sorry for writing all the code :)
>From: Darkfire139@aol.com
>Reply-To: assembly-83@lists.ticalc.org
>To: assembly-83@lists.ticalc.org
>Subject: [A83] My Own Lame Sprite Collision Routine.....
>
> I recently wrote my own sprite collision routine, although I know
>there are better ones, but I wanted to see if mine worked. Well.... It
>doesn't, but it's so simple you would think it would have to work. I hope
>someone could please help me with this or tell me what's wrong without
>giving
>me a different sprite collision routine.
>
>When I want to check for collision I call when_sprites_collide.
>(Sprite1y and Sprite1x are the coords of the sprite that is stationary, and
>x
>and y are the coords of the sprite that moves and collides with sprite1)
>
>when_sprites_collide:
> ld a,(sprite1y)
> add a,8
> ld (botleft),a
> ld a,(sprite1x)
> add a,8
> ld (topright),a
>topleftcheck:
> ld a,(sprite1x)
> ld l,a
> ld a,(x)
> cp l
> ret nz
> ld a,(sprite1y)
> ld l,a
> ld a,(y)
> cp l
> ret nz
> bcall(_getkey)
> ret
>toprightcheck:
> ld a,(topright)
> ld l,a
> ld a,(x)
> cp l
> ret nz
> ld a,(sprite1y)
> ld l,a
> ld a,(y)
> cp l
> ret nz
> bcall(_getkey)
> ret
>botleftcheck:
> ld a,(sprite1x)
> ld l,a
> ld a,(x)
> cp l
> ret nz
> ld a,(botleft)
> ld l,a
> ld a,(y)
> cp l
> ret nz
> bcall(_getkey)
> ret
>botrightcheck:
> ld a,(topright)
> ld l,a
> ld a,(x)
> cp l
> ret nz
> ld a,(botleft)
> ld l,a
> ld a,(y)
> cp l
> ret nz
> bcall(_getkey)
> ret
>
>Thanks,
>darkfire139@aol.com
>
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp