Is there any way in Java (Eclipse) to move a player object that is defined as an object on a matrix tile ?
So, the start position of the player object is (0,0). The playboard is a 12x12 matrix. The existing code that I have written works fine to create the player object (as mentioned, as an object on a matrix tile whereby the matrix is defined as [row,col] ).
I am looking to a method to start moving the player based on certain conditions. e.g. a button (I know how to create). So, the question is really how to start moving the player defined as an object on a matrix tile (PlayerPion in the code below).
Thanks in advance for your responses ;).
GamePanel() {
setLimits(BorderFactory.createLineBorder(Color.BLACK, GAP));
GridLayout layout = new GridLayout(GamePanel.getBoardRows(),
GamePanel.getBoardCols());
setLayout(layout);
for (int i = 0; i <PlayBoard.getBoardRows(); i++) {
for (int j = 0; j < PlayBoard.getBoardCols(); j++) {
int[][] matrixBoard = Board.getBoard();
int boardValue = matrixBoard[i][j];
switch(boardValue) {
case AA: add(new Tile(Color.WHITE));
add(new PlayerPion());
break;
(Code that is not relevant is not shown)
A sample of the playBoard (output from existing code): enter image description here