Making array surface on model for some kind of chess game

Hello friends,

I would like to make some kind of strategic game (similiar to chess).

I have bridge:

I want to make array surface on this bridge. I expect having there squares on which will be placed figures (some kind of models) and by which (squares) will be moving.

On click I should get square from surface which will get another color (if there is a figure) and show me available moves.

I have no idea if I should make plane in blender which will copy bridge surface which will be subdivided (subdivision will make some kind of array) or do it another way?

Or should I make class arraySquare which will have some “x” and “y” dimensions. But still, I have no idea, how to make surface “arrayfied” :smiley:

If you have some ideas how to make it I’m looking forward.


Well there is to different aspects to this problem: The visuals and the in-game representation.

For the visuals, I would copy the bridge surface and make discrete squares out of it as you suggested. You can then for example use raycasting to determine which of the squares was selected by the player.

The internal representation is just a graph really. For each node you have to store its neighbors and maybe things like cost (if you want to have nodes that are more difficult to move through such as swamp etc.). Then you can use usual graph search algorithms such as A* for pathfinding etc.

Thanks for advise.

Is there a way to represent grid as 2-dimensial array?

Or is better to make then separeted objects and work with them?

Cause you know, having 64 or even more squares can be hard to work with.

Any way, I can make a list of them, but how will I get to know that he is his neighbor?

I presume you would name the squares appropriately - e.g. 0-0, 0-1, 0-2, 0-3, 1-0, 1-1, etc…

Then you can loop over them and represent them programatically in a 2D array or whatever.

I read few articles. What about making grid? Isn’t it after all better?

There are best practices, fastest ways and proper useage, but in the end its all about how you find it most readable to yourself. Code generally goes through many iterations as your game and reliance on methods changes anyway.

First make it work, and worry about the rest later. As long as you are learning, there is no such thing as wasted time or code :slight_smile:

1 Like