That's a really good idea, (I'm still wondering how
come I didn't come up with it on my own :) )
But after some thought, I'm just wondering how to
implement both sorted lists into the collision
function.
I mean, my guess is that first you would check the x
sorted list (up one and down one) to see if there is
any overlaping, going further through the list if
there are sprites with the same x coordinate, then
check to see if the x overlap sprites are also
overlaping on the y coordinate too.
But from that, I don't see where using a sorted y
coordinate would make it any faster, expecially in
games like mario where many sprites would be on the
exact same horizontal plane as mario.
I just want to make sure I am understanding your idea
correctly.
Thanks for the help!
--- Jesse McClusky <
thought@...> wrote:
>
> Another way to do it is to have all of your sprites
> in X-sorted and Y-sorted
> linked lists. The list only changes when one sprite
> moves past another one,
> or when you add/remove a sprite, and you only have
> to change a couple of
> pointers when that happens. But the big benefit it
> gives you is that you
> know exactly what the closest sprite in the X and Y
> direction is, so you
> only have to look at the closest couple of sprites
> in each direction, and
> only when a sprite is moving.
>
> > -----Original Message-----
> > From: Phantasm4489
> [mailto:
phantasm4489@...]
> > Sent: Sunday, October 03, 2004 6:15 AM
> > To:
gbadev@yahoogroups.com
> > Subject: RE: [gbadev] Character collision systems
> >
> >
> >
> > 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!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail