How to walk through tiles of infinity extent grid given only single integer parameter?

18 views Asked by At

The walking should include tiles in circular path to make sure all tiles around the center are walked as shown in gif.

The grid is infinite extent, so I cannot use width nor height. They will make no benefit to be used however because I need to walk in order of how much the tile is near to the center.

black represents the center (startup tile) red is the displaced tiles

the alghorithm head can be like this:

walk(center: TileIndex, d: Int)
    if d == 0
        return center
    else
       ...

I need help to do the rest. I'm also curios if this even possible. I've searched about this but couldn't find somone who has a similar problem.

0

There are 0 answers