I have a blackjack program and I want to show the cards with 1 second delay. When I use Thread.sleep(1000)
it waits and shows all of the cards at the same time.
do {
neueKarte(new ActionEvent());
Thread.sleep(1000);
} while (bot.getValue() <= 16);
shows all the images after finishing with the loop, not every second
@FXML private void neueKarte(ActionEvent event) throws Exception {
if(spielerDran == true) {
sp1.nimmKarte(deck, 1);
punkte.setText("Deine Punkte: " + Integer.toString(sp1.getValue()));
naechstesFeld().setImage(sp1.hand.get(sp1.hand.size()-1).getImage());
if(sp1.hand.size()==2) {
aussteigen.setDisable(false);
}
if(sp1.getValue()>=21) {
zieheKarte.setDisable(true);
aussteigen(new ActionEvent());
}
} else {
bot.nimmKarte(deck, 1);
botPunkte.setText("Computer Punkte: " + Integer.toString(bot.getValue()));
naechstesFeld().setImage(bot.hand.get(bot.hand.size()-1).getImage());
}
}