Trying to make a board game. Help please

so , the thing is that i’m trying to make a board game, I have already solved the making the dice problem, but I don’t know how to “divide” the board in boxes, so the player can move between them with the dice result. Any ideas? I’m totally blocked :frowning: :frowning:

1 Like

The player can decide how to move or there is only one way in the board?

only one way, it’s some sort of snakes and ladders

If the board is made of multiple “Cell” objects, you should add an “ID” variable to each Cell instance, with the number of the cell, this way the first Cell will have ID = 1, the second Cell ID = 2, etc.
Now you need to know the Player position, do it with a “Pos” variable, it will save the current Player cell.
Finally, when you throw the dice and get the random number, add the value to the Player Pos variable, and move it to the Cell with the same ID:

[code]Conditions: At the beginning of the scene
Variable ID of Cell is = 1
Actions: Do = 1 to the variable Pos of Player
Do X = Cell.PointX(Centre); Y = Cell.PointY(Centre) to the position of Player

Conditions: After you get the random number from the dice in a variable Dice_Number
Actions: Do + Variable(Dice_Number) to the variable Pos of Player
// Sub-event
Conditions: Variable ID of Cell is = Player.Variable(Pos)
Actions: Do X = Cell.PointX(Centre); Y = Cell.PointY(Centre) to the position of Player[/code]

If the board is a big single object, we have a problem because GD doesn’t support dynamic point access (you can’t do Cell.PointX(VariableString(dynamic_point_name) ), if you really need it you can generate a list in a structure variable, mapping a cell id (1, 2, 3) to a position (125;455 , 321;255 , 15;603), then do the same as above but with the structure variable instead the Cells:

Conditions: After you get the random number from the dice in a variable Dice_Number Actions: Do + Variable(Dice_Number) to the variable Pos of Player // Sub-event Conditions: No conditions (always) Actions: Do X = Variable(List[Player.VariableString(Pos)].x); Y = Variable(List[Player.VariableString(Pos)].y to the position of Player

1 Like

I couldn’t expect a quicker answer, thx! The thing is that the board is a big single piece, so I will try my best :unamused: :unamused:

And to think that adding dynamic points is easy as changing two lines in the sources, but it would be a compatibility breaker, because current projects’ actions using static points (without “”) won’t work :frowning: