You could use the two techniques you describe at the same time, by having a
collision map which is of a lower resolution than the spite movement.
so have a collision map which is say on eight pixel boundaries and each time
an object moves you write the object number into the collision map at the
relevant place.
Then you will know which sprites you need to check rather than looping
through all of them.
Depending on the size of the collision you choose, you may also have to
consider that there could be more than 1 object in any location.
_____
From: Palamon 3 [mailto:
palamon_3@...]
Sent: 03 October 2004 04:37
To:
gbadev@yahoogroups.com
Subject: [gbadev] Character collision systems
Hi,
I've been trying to figure out a good way to detect if
two objects touch each other in an action game like
mario brothers.
The first game I am making, I wanted to take the easy
road so I have the sprite characters simply move in 8
pixel increments, so they always stop aligned with the
background tiles, just like in the Pokemon games. I
keep track of the different sprite characters through
creating a big 2d array about the size of the
background array, and I simply keep track of where the
different sprite characters are by putting markers on
the game map based on their xy coordinates so is is
easy to see if they collide with anything by simply
checking the xy coordinates in the map array that is
right next to the other sprite character.
It's an easy and quick way to keep track of the
different locations and see if the different sprite
characters collide with each other, etc.
However this only works for games that have only a few
set spots where the sprite characters can be, not
games like mario and other action games where your
character can move pixel by pixel. I'm afraid the map
array becomes too big to be the best option for the
job, plus you have to fill up every pixel of the map
array that the sprite takes up, which will slow it
down.
The only other option I can think of is to scroll
through a list of all the sprites on screen and check
their xy coordinates and the sprite width/height to
see if it overlaps the sprite character you are
checking to see if those sprites collide or not. I'm
hesitant to do this because I'm afraid it will be too
slow when the sprite list is a little large since it
has to run though all the sprite characters and their
positions every time something moves.
I was wondering what programming techniques you all use.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Yahoo! Groups Sponsor
ADVERTISEMENT
<
http://us.ard.yahoo.com/SIG=129vpfoqv/M=315388.5455592.6541275.1666179/D=gr
oups/S=1705055196:HM/EXP=1096894128/A=2372354/R=0/SIG=12id813k2/*https:/www.
orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS> click
here
<
http://us.adserver.yahoo.com/l?M=315388.5455592.6541275.1666179/D=groups/S=
:HM/A=2372354/rand=177280909>
_____
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/gbadev/
* To unsubscribe from this group, send an email to:
gbadev-unsubscribe@yahoogroups.com
<mailto:
gbadev-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo!
<
http://docs.yahoo.com/info/terms/> Terms of Service.