# How can I use a data grid to make an isometric turn based game in GameMaker?

I am making a Hero Quest clone. It is a turn based adventure game with an isometric view point. So far I have been able to turn a 2D map into an isometric view but I believe I need to use a data grid to achieve turn based movement, combat etc.

There are plenty of tutorials on data grids but none that I can find on how to translate a 2D grid to a psedo-3D isometric game.

How could I do it?

## 2 Answers

Using a data structure to save level data is a good idea, as there are many games using voxel engines to deal with this kind of information.

A voxel engine is essentially an engine that stores level data into an appropriate data structure (a list, a grid, or even a 3D matrix as Minecraft does), and uses it to recreate levels in your game. Voxel engines are commonly used in 3D games, but you can take advantage of the idea behind it to apply into your own game.

Let's start with an easy example: chess. A chessboard is a 8x8 grid, on which pieces are moved and placed (also, it's turn-based like your game). You can have plenty of different chessboards in the world, with different sizes and colours. But they have one thing in common: coordinates. You can always replay a chess game on any chessboard, because they all share the same coordinate system and pieces assets.

As you can see, this is a simple example where game "logic" and game "rendering" are separated: chess rules are independent from the chessboard style and design, as long as there's a reference to a 8x8 grid on them.

That's the strategy you can follow. If your level consists of an isometric map where you can define a certain number of horizontal and vertical tiles, the only thing you need to do is mapping these tiles to an appropriate allocation in a ds_grid data structure.

### A simple grid

Let's say we want to create a diamond-shaped level, and we consider a grid data structure to store information about tiles: the indexes in the data structure are multiplicated times the width/height to fit our graphic resources in the room (plus any offset). Data stored in grid[0,0] will be placed in our room at position (0,0), whereas the data grid[0,1] - which is the neighbor tile on the left, will be placed at position (0,1*tile_width), so (0,tile_width).

To see a possible result, consider the following 6x6 grid where 0 means grass and 1 is a solid wall:

1 1 1 1 1 1
1 0 0 0 0 1
1 0 0 0 0 1
1 0 0 0 0 1
1 0 0 0 0 1
1 1 1 1 1 1


Using the appropriate function to map data to 2D tiles, that's the result:

Once you fix the (0,0) position in your world, all other tiles are positioned relative to this one.

You can find many tutorials on Youtube to get started with isometric design.

• Thank you very much for such a comprehensive answer! I will read carefully what you have written and will apply it to my game. May 26, 2016 at 13:10
• What engine did you build this with? I'd like to build a puzzle/strategy game that requires a 3d n x n tile board. Each tile represents a receptacle for water. Players move water from receptacle to receptacle by raising and lowering gates between each receptacle, until it flows off the board, and into a players bucket; which lies inside one of the receptacles at the edge of the board. Oct 12, 2016 at 19:29
• You can use virtually any engine you prefer. Work with Game Maker, Unity, Pencil, or any other environment that provides an IDE, physics and sound engine and many built-in functions. Otherwise, you can build your own engine from scratch by using any language (C++, C#, Java...) and any graphic library (OpenGL, Direct3D, libGDX), and so on... Oct 12, 2016 at 20:04

Usually when you work with an isometric perspective all the data and logic is still done in normal 2D and then you translate it to isometric.

Especially if you do a grid based game cause the grid is actually the same. The only difference is how it's drawn. Like in most isometric games the tile in the top end has the index (0,0) and then, depending on how you sort, the tile down to the right has index (1,0) and so on which give you a normal 2d grid to have the data and logic on.

• This is exactly what I wanted to know, thanks. Now I will go ahead and continue making the game using a 2D grid and then try to work out how to make it display in the isometric style later. I just wanted to check that it would not be a big waste of time. May 26, 2016 at 13:01