Sign in to follow this  

how to wrap a scene?

This topic is 4854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, im using a quadtree for a realy big level and I was wondering how to wrap it? ie. If part of a sprite is half out at the top of the game it will be half in at the bottom.

Share this post


Link to post
Share on other sites
You want the scene to wrap around the edges? Setup a utility function to get the edge quadrants of a quad, which should automatically seek past the edge of the level and use the quads on the other side. i.e.


void RenderQuads()
{
render( currentQuad.getQuad( QD_TOP ) );
render( currentQuad.getQuad( QD_LEFT ) );
...
}

Quad *Quad::getQuad( QuadType quadType )
{
switch ( quadType )
{
case QD_TOP:
if ( this->position.y == 0 )
{
return quadList[this->position.x][lastQuadY];
}
else
{
return quadList[this->position.x][this->position.y - 1]
}
...
}

return NULL;
}



That is overly simplified, but you get the idea. Also, I'm sure that there are better ways, but this one's fairly simple. There's probably also better ways to implement this one.

Hope it helps, and happy coding!

Share this post


Link to post
Share on other sites
Thank you for you help, I see what your saying. Just write a function to find the needed edge leafs. That is the first half of my problem. The second is how to transition sprites to and from opposite sides of the map. Including the posiblity that a sprite could be in two or more nodes at once. Is there a tutorial anyone knows about that discusses quadtree scene managment pertaining to wraping a scene?

Share this post


Link to post
Share on other sites

This topic is 4854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this