Skip to main content
replace broken ImageShack image with a redrawn illustration; misc. copyedits
Source Link
Ilmari Karonen
  • 8.4k
  • 1
  • 31
  • 39

I'm making a game using in C# and Javascript that uses a map which havehas tiles, corners and borders. Here's a graphical representation:

Tiles, Borders and Corners http://img543.imageshack.us/img543/2180/tileso.pngTiles, Borders and Corners

I've managed to store tiles and corners in memory but I'm having troubles to gettrouble getting the borders structured.

For the tiles, I have a [Map Width * Map Height]Map Width * Map Height sized array. For corners I have [(Map Width + 1) * (Map Height + 1)](Map Width + 1) * (Map Height + 1) sized array. I've

I've already made up the math needed to access corners from a tile, but I can't figure out how to store and access the borders from a single array.

Tiles store thetheir type (and other game logic variables) and via the array index I can get the X, and Y coordinates. ViaFrom this tile position it is possible to get the array index of the corners (which store the Z index).
The borders will store a game object and accessing corners from only border info would be also required.

If someone even has a better way to store these for better memory and performance I would gladly accept that.

EDIT: Using in C# and Javascript.

I'm making a game that uses a map which have tiles, corners and borders. Here's a graphical representation:

Tiles, Borders and Corners http://img543.imageshack.us/img543/2180/tileso.png

I've managed to store tiles and corners in memory but I'm having troubles to get borders structured.

For the tiles, I have a [Map Width * Map Height] sized array. For corners I have [(Map Width + 1) * (Map Height + 1)] sized array. I've already made up the math needed to access corners from a tile, but I can't figure out how to store and access the borders from a single array.

Tiles store the type (and other game logic variables) and via the array index I can get the X, Y. Via this tile position it is possible to get the array index of the corners (which store the Z index).
The borders will store a game object and accessing corners from only border info would be also required.

If someone even has a better way to store these for better memory and performance I would gladly accept that.

EDIT: Using in C# and Javascript.

I'm making a game using in C# and Javascript that uses a map which has tiles, corners and borders. Here's a graphical representation:

Tiles, Borders and Corners

I've managed to store tiles and corners in memory but I'm having trouble getting the borders structured.

For the tiles, I have a Map Width * Map Height sized array. For corners I have (Map Width + 1) * (Map Height + 1) sized array.

I've already made up the math needed to access corners from a tile, but I can't figure out how to store and access the borders from a single array.

Tiles store their type (and other game logic variables) and via the array index I can get the X and Y coordinates. From this tile position it is possible to get the array index of the corners (which store the Z index).
The borders will store a game object and accessing corners from only border info would be also required.

If someone even has a better way to store these for better memory and performance I would gladly accept that.

edited tags
Link
Tweeted twitter.com/#!/StackGameDev/status/49340279119024128
added 37 characters in body
Source Link
JPiolho
  • 315
  • 2
  • 7

I'm making a game that uses a map which have tiles, corners and borders. Here's a graphical representation:

Tiles, Borders and Corners http://img543.imageshack.us/img543/2180/tileso.png

I've managed to store tiles and corners in memory but I'm having troubles to get borders structured.

For the tiles, I have a [Map Width * Map Height] sized array. For corners I have [(Map Width + 1) * (Map Height + 1)] sized array. I've already made up the math needed to access corners from a tile, but I can't figure out how to store and access the borders from a single array.

Tiles store the type (and other game logic variables) and via the array index I can get the X, Y. Via this tile position it is possible to get the array index of the corners (which store the Z index).
The borders will store a game object and accessing corners from only border info would be also required.

If someone even has a better way to store these for better memory and performance I would gladly accept that.

EDIT: Using in C# and Javascript.

I'm making a game that uses a map which have tiles, corners and borders. Here's a graphical representation:

Tiles, Borders and Corners http://img543.imageshack.us/img543/2180/tileso.png

I've managed to store tiles and corners in memory but I'm having troubles to get borders structured.

For the tiles, I have a [Map Width * Map Height] sized array. For corners I have [(Map Width + 1) * (Map Height + 1)] sized array. I've already made up the math needed to access corners from a tile, but I can't figure out how to store and access the borders from a single array.

Tiles store the type (and other game logic variables) and via the array index I can get the X, Y. Via this tile position it is possible to get the array index of the corners (which store the Z index).
The borders will store a game object and accessing corners from only border info would be also required.

If someone even has a better way to store these for better memory and performance I would gladly accept that.

I'm making a game that uses a map which have tiles, corners and borders. Here's a graphical representation:

Tiles, Borders and Corners http://img543.imageshack.us/img543/2180/tileso.png

I've managed to store tiles and corners in memory but I'm having troubles to get borders structured.

For the tiles, I have a [Map Width * Map Height] sized array. For corners I have [(Map Width + 1) * (Map Height + 1)] sized array. I've already made up the math needed to access corners from a tile, but I can't figure out how to store and access the borders from a single array.

Tiles store the type (and other game logic variables) and via the array index I can get the X, Y. Via this tile position it is possible to get the array index of the corners (which store the Z index).
The borders will store a game object and accessing corners from only border info would be also required.

If someone even has a better way to store these for better memory and performance I would gladly accept that.

EDIT: Using in C# and Javascript.

Source Link
JPiolho
  • 315
  • 2
  • 7
Loading