I'm using Gameplay3d as a game engine to develop a simple board game, PEG Solitaire.
I've come to the part where I've created a 2D grid for all the movable object, empty locations and also where it's not movable. I'm now trying to somehow map that 2D grid to my actual game coordinates, translations of my pieces. Using Gameplay I can select my objects. What I'm trying to figure out is how to solve this actual problem to map my grid to the actual movement of the game pieces?
I was maybe thinking of using an
std::map<char*, int> where "
char*" is the NodeID and "
int" is the index in the 2D grid list so that I can identify each Node and where they are in my 2D grid. The problem I'm having now is how can I solve the problem if the user select places on my board that doesn't have moveable piece. Let's say the user clicks on an empty hole on the PEG Solitaire board. How can I map that location to my 2D Grid?
I've created my board model and Sphere using Blender. I can using Gameplay use raypicking and select the differente Sphere Nodes and the whole Board Node. The problem is that I can't pick the individual holes on the Board as Nodes. I know the center position of each hole on the board. So my solution was to somehow first figure out the Spheres world size maybe translate it to the screen size. When the user then clicks on the screen I can check if the position of x and y is inside the selection area of that hole so to say. I'm probably just wondering away in my own thought. But any detailed help here would be appreciated.
Get object world size and translate to screen size of possible.
The 2D grid looks like this:
0022200 0022200 2222222 2221222 2222222 0022200 0022200