Last active
October 25, 2016 11:15
-
-
Save alexanderbazo/3e8b74267d8419794406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compound board = new Compound() | |
private void initBoard(int fieldWidth, int fieldHeight) { | |
board = new Compound(0, 0); | |
for (int x = 0; x < ROWS; x++) { | |
for (int y = 0; y < COLUMNS; y++) { | |
Chessfield newField = getNewFieldForBoard(x, y, fieldWidth,fieldHeight); | |
board.add(newField); | |
} | |
} | |
} | |
private Chessfield getNewFieldForBoard(int xIndex, int yIndex, | |
int fieldWidth, int fieldHeight) { | |
Chessfield newField; | |
int xPos = xIndex * fieldWidth; | |
int yPos = yIndex * fieldHeight; | |
if ((xIndex + yIndex) % 2 == 0) { | |
newField = new Chessfield(xPos, yPos, fieldWidth, fieldHeight,Color.BLACK); | |
} else { | |
newField = new Chessfield(xPos, yPos, fieldWidth, fieldHeight,Color.WHITE); | |
} | |
return newField; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment