I want to add combat in my game, how would i make it so that a user only has a specific amount of time to enter a key - combo ex
String[] arr = {"A", "B", "C", "D", "E", "F"}; Random random = new Random();
int fight = random.nextInt(arr.length);
if (arr[fight].equals("A")) {
System.out.println("You encountered an enemy!, Get ready to fight!");
try {
Thread.sleep(2000);
} catch (InterruptedException f) {
}
System.out.println("The enemy shoots a bullet!");
System.out.print("Enter \"10110\" to dodge!: "); ---------
pressp = i.next();-------- only 1 second to enter "10110"
try { else you get shot by bullet.
Thread.sleep(1000);
} catch (InterruptedException f) {
}