Hi all, sorry if this is fairly simple, but I’ve been working on it for a week or so now and can’t seem to find a solution based on my limited programming skills.
So in the game, a bunch of tiles are instantiated in grid formation, labeled with their x and y location, added to an array, and then player can move from tile to tile one at a time.
Once you reach an edge tile, the game should calculate which overall section/collection of tiles from the first edge tile you left to the final edge tile you landed on, has the smaller number of tiles (or other similar queries). It should then change these tiles to whatever you’d like (for example, if all the tiles represent dirt, the new smaller section will change to grass tiles). So it isn’t just the ones you’ve collided with, but each tile you’ve collided with closest edge neighbor and all the tiles in between.
It’s a little hard to explain so I made an example gif here of the process, I hope it makes sense.
My problem is I’m struggling to find a way for the game to understand which tiles to affect. I’ve tried recording each tile you land on, then having all those tiles calculate which edge is closer, collect those tiles, and affect the tiles based on that. But the problem is if you walk in an irregular path, or occasionally close to one edge, it will affect tiles outside of the collective area, instead of keeping it all inside.
I’m kind of losing my mind and I’m sure there’s a simple way to do this that I just can’t get to. I’d love any / all suggestions on how to possible accomplish this? Thank you all so much in advance for giving this question a look. I’m using C#.