Figuring out if 2 "links" are connected in a 2D map So I am trying to build a game with a 2d world similar to RimWorld / Prison Architect / SimAirport / etc. and trying to figure out a way to split up the world to make it easier to query for close by objects and such. The game will have a lot of items on the map and the map will be a relatively big shooting for a minimum of 200 x 200 but would like to be able to go so sizes like 300 x 300 or 350 x 350 if possible so if I want to find the closest X and there 500 X on the map, looping through each X and checking the distance and figuring out the closest one will not scale (I've tried). Currently I have a region system that breaks the map up into 12 x 12 sections and each region keeps a list of items that need to be queries, This makes it quick to just first search the regions closest to see if they have the item being looked for and then it a region does, just checking the items in that region for distance instead of them all. This system was inspired by the video the RimWorld's developer put on basically describing this however there is one issue I am running into. Right now my regions are fixed and if there is a structure that is fully enclosed, my region system still thinks the enclosed area is part of that region and accessible even if it is not. In the video he shows that if there are region that are cut up by impassible tiles, those regions would be split up and the 2 would not think they are connected at the point. While I have an idea on how to split the regions up by impassible tiles, how to properly makes sure the regions are not connected is a little harder for me to understand. At this point of the video: https://www.youtube.com/watch?v=RMBQn_sg7DA&feature=youtu.be&t=1361 He describes a system where each region store some pieces of information about each link (direction, length, starting x, and starting y) as an int using different bits for those pieces of information and while I think I have figured out how to do that, what I don't understand is how I can use that data to efficiently figure out which regions are linked without having to make sure the data structure is in a specific order so that those regions can be removed / add in any order. This is the code I have so far: https://ift.tt/2zE1t7o Is there a way with that data to be able to determine that link 1 / 2 / 3 are connected but link 4 is not? https://ift.tt/eA8V8J
So I am trying to build a game with a 2d world similar to RimWorld / Prison Architect / SimAirport / etc. and trying to figure out a way to split up the world to make it easier to query for close by objects and such. The game will have a lot of items on the map and the map will be a relatively big shooting for a minimum of 200 x 200 but would like to be able to go so sizes like 300 x 300 or 350 x 350 if possible so if I want to find the closest X and there 500 X on the map, looping through each X and checking the distance and figuring out the closest one will not scale (I've tried). Currently I have a region system that breaks the map up into 12 x 12 sections and each region keeps a list of items that need to be queries, This makes it quick to just first search the regions closest to see if they have the item being looked for and then it a region does, just checking the items in that region for distance instead of them all. This system was inspired by the video the RimWorld's developer put on basically describing this however there is one issue I am running into. Right now my regions are fixed and if there is a structure that is fully enclosed, my region system still thinks the enclosed area is part of that region and accessible even if it is not. In the video he shows that if there are region that are cut up by impassible tiles, those regions would be split up and the 2 would not think they are connected at the point. While I have an idea on how to split the regions up by impassible tiles, how to properly makes sure the regions are not connected is a little harder for me to understand. At this point of the video: https://www.youtube.com/watch?v=RMBQn_sg7DA&feature=youtu.be&t=1361 He describes a system where each region store some pieces of information about each link (direction, length, starting x, and starting y) as an int using different bits for those pieces of information and while I think I have figured out how to do that, what I don't understand is how I can use that data to efficiently figure out which regions are linked without having to make sure the data structure is in a specific order so that those regions can be removed / add in any order. This is the code I have so far: https://ift.tt/2zE1t7o Is there a way with that data to be able to determine that link 1 / 2 / 3 are connected but link 4 is not?
from GameDev.net https://ift.tt/2PzKVsa
from GameDev.net https://ift.tt/2PzKVsa
ليست هناك تعليقات