NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Can someone explain collision detection in english?  
Posted byMemblers
Posted on10/30/02 09:25 AM
From IP68.58.96.167  



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.



-
Entire Thread
Subject  Posted byPosted On
*Can someone explain collision detection in english?  FistOfFury10/30/02 08:50 AM
..Re: Can someone explain collision detection in english?  Memblers10/30/02 09:25 AM
..*Re: Can someone explain collision detection in english?  FistOfFury10/30/02 10:30 AM
...*Re: Can someone explain collision detection in english?  Memblers10/30/02 10:38 AM
....*Re: Can someone explain collision detection in english?  FistOfFury10/30/02 10:43 AM
.....*Re: Can someone explain collision detection in english?  koitsu10/30/02 11:26 AM
......*Re: Can someone explain collision detection in english?  FistOfFury10/30/02 11:34 AM
.....*Re: Can someone explain collision detection in english?  Memblers10/30/02 10:46 AM
......*Re: Can someone explain collision detection in english?  FistOfFury10/30/02 10:54 AM
.......*Re: Can someone explain collision detection in english?  Memblers10/30/02 11:03 AM
.....*Re: Can someone explain collision detection in english?  FistOfFury10/30/02 10:45 AM
....*Re: Can someone explain collision detection in english?  Memblers10/30/02 10:42 AM
..*Re: Can someone explain collision detection in english?  koitsu10/30/02 09:39 AM
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo