Grid based Navigation system

Ok so I am curious as to how I should create a grid layout that tells the player where in the map they are. I googled the **** out of this topic and the closest thing I found to what I was looking for was Grid Style Movement, but thats literally moving based on a grid. I want something that simply tells the player where they are in the world based on what grid tile theyre in. EX:

New York City

[table=“width: 500, class: fill_grid”]

Northwest
North
Northeast


West
Central
East


Southwest
South
Southeast

If they player is in the “North” tile, then the zone will be “New York City - North” same as the rest of the zones.

I’m just simply asking for some pointers or maybe a tutorial link or something. I am not asking for someone to do the work for me, unless they want to or even walk me through it. Either way, I’d like to learn it rather than have someone do it for me. Thanks!

You can do this with a series of arrays, or combine it into one struct array.

My data structure looks like this:

So the lower right corner is index 0 in the array. I have the tile vector, precipitation, and every other bit of info about the bottom right corner tile in index 0 of every array that references the map. So on map size 10 the first row is 0 through 9. The second row is 10 through 19, and so on.

So in your example, lets say Southeast is stored at index 0. Then in another array you could store info about Southeast in the same index; 0. Anytime you want anything about Southeast you know to go to index 0. You get the idea.

More practically, you can create a struct that has all the info about a given tile, and then make an array of that struct. That way you only need to access the array once for all the info on a tile at any given time.

Hi EscapeTheFate0921,

I do lots of 2D Grid work for procedural generated Roomsand Dungeons. I use them in my current Dungeon Crawler. There are many ways to approach this. Firstly, I would anticipate using some method to store Grid Cell location Names. Secondly, a form collision detection/calculation between player and Grid Cell.

A good place to start is with the Grid or Matrix itself. A 2D Grid has X,Y Planes. You can divide these up Rows and Columns to create Cells, then its simple math to calculate player location in relation to cells dimension or group of cells. The :cool: player is located in Cell[3,1] to move we use these simple formula to move n cells.
[FONT=courier new]
X = Horizontal[FONT=courier new]|Column, Y = Vertical[FONT=courier new]|Row

North = [FONT=courier new]X, Y-n
South = [FONT=courier new]X, Y+n
East = [FONT=courier new]X+n, Y
West = [FONT=courier new]X-n, Y

[TABLE=“class: grid”]

0

1
2
3
4
5
6
7
8
9

0

1

:cool:

2

3

4

5

6

7

8

9

The following formulas can provide the basis for setting up the collision detection/calculation between player vs grid cell and should provide player positioning mechanism. For simplicity we assume each Cell is equivalent in size width and depth. We can calculate the Cells location in 3D space based on its column and row in the Grid, [FONT=courier new]Cell[column,row] Multi-dim to Linear Conversion: [FONT=courier new]Column * Max.Row + Row. In 3D Space the cell location vector {x,y,z} can be calculated by [FONT=courier new]cell.location = {cell.width * column, [FONT=courier new]cell.depth * row, 0}

Using arbitrary value for width = 50, depth=50, we can calculate the location of the player in relation to the Cell. So if the Player is location 135,51,100 we can divide x/width, y/depth, z0(not used) for 135/50, 51/50, 1000 → 3,1,0 → Cell[Column=3, Row=1]

Thanks for the replies guys! Ill look into these methods and see what I can come up with! :slight_smile: