Grid Terrain/Node of 8x8 squares?


is there a way to make 8x8 squares of any size for battlefield?

I went through many topics here but most of them have links which are not active anymore.
Makes thing harder.

I have model from blender “bridge” and I want to make that type of battlefield there for strategic game.

I found Grid grid = new Grid(int xLines, int yLines, float lineDist); // but I don’t get at all how to use it.
On click the square would change color but that’s not that hard.
What is output of Grid? Is it some type of array or anything else?
After all documentaion I went through I have still no idea how to use it, if I have to use it.


So… you did all of the tutorials and still don’t know how to put a mesh into a scene? That seems odd.

A grid is probably not what you want, though… it’s a grid of lines.

So… you did all of the tutorials and still don’t know how to put a mesh into a scene? That seems odd.

I know how to put mesh into a scene.

I just can’t find correct way to make “battlefield” where I would have some figures to work with, make them move etc.

Imagine chess game. There is array 8x8 where all figures move. I want the same thing applies on terrain.

There are a few ways to do this. If you’re talking about a grid “painted” onto terrain and following contours, that’s going to be tricky to do. If not, I’d suggest making an 8x8 grid of cubes (same height coordinate, space them appropriately).

Makes sense, thanks. Just, how will I work with them then?
Imagine clicking on figure it will show you squares where you can move (on the battlefield) and so on.
How will I access them?

It really depends on your game logic… for a grid though, it probably makes sense to keep a 2D array. Clicking on things in the scene graph is covered in one of the tutorials (you can attach the x/y grid coordinates to a node as user data), and @pspeed’s outstanding Lemur library provides much more sophisticated support for that.

Edit: Also, clearly divide in your head what you know about your game and what you see. In chess you have a bunch of pieces, and each piece has a position on the board and rules about how it can move. This is what you know about chess, and any chess game will have to use this information. Now that you have that, you can display it any way you like (2D, 3D, highlighting legal move squares, etc). It is very, very important for a good design to keep what you know and what you see as separate things. The formal name for this is “MVC” (Model View Controller), and it comes up a lot in software development. The better you differentiate between what you know and what you see, the better you can separate your game rules from the code that displays your game and the easier your life will be.

Thanks for your advice.

Let’s say, I want to make exact chess game on terrain. What should I do? I want to make battlefield of 8x8. Which feature I should use for it which will help me later to make moving pieces easier (to work with array?).

You would keep a reference of the object you add to the scene. I’m not sure you have the capability yet to do what you are trying to do. What level of programmatical skill would you consider yourself? You should really go through the beginner tutorials first…