![]() We can automatically set up the map at runtime by looking at the plot and each tile model: local PLOT_GRID_SIZE = 4įor _, tileModel in pairs(:GetChildren()) do In Lua, such a 2D map could be defined like this: function mapGet(map, c1, c2)Īssert(c1 % 1 = 0 and c2 % 1 = 0, "mapGet shouldn't be called with non-integer coordinates")Īssert(c1 % 1 = 0 and c2 % 1 = 0, "mapSet shouldn't be called with non-integer coordinates") ![]() ![]() integers) and each value is a tile in the plot, which can be a model, or a table containing info about the tile. I don’t know what data structure you’re using for the plot tiles, but I would go with a “2D coordinate to tile map”, or more formally an associative array where each key is a pair of coordinates (i.e. You’ll need some definition of what tiles are neighboring, and a definition of what tiles can/cannot be traversed by the filling algorithm. If that’s the case, then yeah flood fill definitely works. You have a building “plot” where walls can be built by the player in a grid, and you want to look through the entire plot and find all the fully enclosed rooms? And by “finding rooms” you mean a list of “plot/grid tiles”? Okay let me see if I’m understanding you correctly now xD ![]() I want to check the entire plot for multiple said rooms. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |