Im working on a game in JavaFX. It's almost done but I encountered problem with move detection and can't think of simple solution. There probably is, but I'm just not aware of that
Obviously there is more code in between but i'm highlighting the problematic part.
int finalX = x;
int finalY = y;
boolean jumpMade = false;
boolean moveMade = false;
// Mouse Controller
board[x][y].setOnMouseClicked(event -> {
if (!moveMade) {
move(finalX, finalY, selectedMarbleX, selectedMarbleY, selectedMarbleColor);
// Here I would want to make moveMade = true;
// To block further possibility of moving.
}
}
Tried changing to atomic or into one-element array but that won't do the job because the "map" that user is playing on have more than one possible direction of moving (so it wont block all of them).
And the error that appears by just placing nonchalantly moveMade = true overthere brings up "Variable in lambda expression should be final or effectively final".