Jump to content

moving an x,y between chunks


ThunderAI

Recommended Posts

I am looking for advice on the best way to achieve the following:

 

say you have a player at a given x,y that can be moved to another x,y.  The player is on a map that is a grid of 38x38 squares, furthure say you can see a total of 64 squares (8x8 grid). There are an unlimited number of map grids (chunks) which are related to each chunck by a field north, east,west, and south where the value in the field is the ID of the chunk next to it in that direction.

 

If there were no chunks you could just search the database for all squares within sight of the player, but this process is more complicated with chunks as a simple search does not result in all viewable sqaures because some would be in different chunks.

 

How do I find the squares that are viewable in a different chunk from my players perspective?

 

Thanks for anything you can help me with.

Link to comment
Share on other sites

How are you storing this all? How do you position each chunk in the larger map? Using two sets of x,y coords should be easy.

 

What's the point in storing this data in chunks, anyways?

 

A lot of what you wrote is hard to follow. I don't have a clear picture of how you've set up your system.

Link to comment
Share on other sites

If I understand you correctly, you would look at adjacent chunks if they are within the viewable area.  I can't really give a more detailed answer than that as there's not much detail of your implementation in the question.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.