这是一个可以“掷骰子”的游戏
我希望数字1-6在控制台中被旋转,直到玩家按下一个键。按下时显示的数字是要选择的数字。
谢谢!
我的代码看起来像这样:
do {
System.out.print("\b1");
Thread.sleep(100);
if (System.in != null) {
dice1Player = 1;
break;
}
System.out.print("\b2");
Thread.sleep(100);
if (System.in != null) {
dice1Player = 2;
break;
}
System.out.print("\b3");
Thread.sleep(100);
if (System.in != null){
dice1Player = 3;
break;
}
System.out.print("\b4");
Thread.sleep(100);
if (System.in != null){
dice1Player = 4;
break;
}
System.out.print("\b5");
Thread.sleep(100);
if (System.in != null){
dice1Player = 5;
break;
}
System.out.print("\b6");
Thread.sleep(100);
if (System.in != null){
dice1Player = 6;
break;
}
Thread.sleep(100);
} while (!Thread.currentThread().isInterrupted());