Scanner sc = new Scanner(System.in); while (true) { int a = sc.nextInt(); for (int j = 0; j < 2000000000; j++) { } if (a == 1 || a == 2) { if (a == 1) {//左移 System.out.println("左移"); } else if (a == 2) {//右移 System.out.println("右移"); } System.out.println("下落"); } }???????????????問題是:程序遇到?sc.nextInt();就會暫停。俄羅斯方塊中的下落時不需要玩家操作的,玩家只操作左右(暫時不考慮變形)我想要的效果是,每過2000000000,方塊就是下落一次,如果玩家有輸入1或者2就進(jìn)行左右移動的操作,沒有輸入就不左右移動。只是sc.nextInt();會讓程序暫停,怎么破?
添加回答
舉報
0/150
提交
取消