[A83] My Own Lame Sprite Collision Routine.....


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

[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