Hello.
I'm making the Dame, a game similar to chess.
This is the board (screenshot):
http://prntscr.com/hqr0hgI'm trying to position the pawns into the Black cells through this algorythm
sprites[i++].setPosition(Vector2f(sizeEdge + sizeMargin + ((currentSquare - 1)*sizeRectangle), sizeEdge + sizeMargin + sizeRectangle*r));
currentSquare += 2; // the next black slot can be found after 2 slots
sizeEdge and
sizeMargin are two areas of the board the pawn needs to move away from.
Here is an image that illustrates this:
http://prntscr.com/hqr4ruThe
edge is not part of the board and the
margin is required to center the pawn into the rectangle.
(currentSquare - 1)*sizeRectangle is a simple calculation to get the number of rectangles the pawn needs to move away from (because they're either white - inaccesible - or occupied by other pawns before)
The result of the algorythm is this:
http://prntscr.com/hqr61mAs you can see
(ignore the white pawn) the more we move to the right, the more the position of the pawns is uncorrect.
And this also repeats for the rows below.
I can't understand where's the issue here. My mathematical formula looks correct... what is causing this issue?
Thanks in advance!