|
The easiest way to do it seems to be using square or rectangular boxes, and checking when they overlap. I'm sure there's other ways to do it, probably better ones to, but here's how I'm doing it in a game. This is only covers sprite-to-sprite collisions.
Say a sprites Y coord is $60. You'd load that into A, then compare it to the Y coord of something it could potentially hit. This will set the carry flag to use in a greater-than/less-than check.
LDA player_y CMP enemy_y BCS player_is_above_object CLC ; not really neccessary because we know the carry is clear =) ADC #8 ; make the 'box' 8 pixels high CMP enemy_y BCS player_hit
Now, I might've screwed that example up (the code in my game is maybe too complicated to make a good example), but hopefully this explains the basics.
|