Sorry from my bad english, not native speaker. I am working on a SimonSays Game on Java in a GUI. Im new to coding. I managed to make the aplication work on console, however its been a mess to make it work graphically. The program compares the LinkedLists from the generated sequence (secuenciaSimon) to the one entered by the user throught buttons (secuenciaUsuarioGUI) however, the problem is that the compare method is called by a click on any button so the LinkedList from the generated Sequence by simon is larger that the one introduced by the user.
Yellow Button Code
private void bAmarilloMousePressed(java.awt.event.MouseEvent evt) {
secuenciaUsuarioGUI.add(3); //Adds the selection to the LinkedList yellow=3
System.out.println("Secuencua Usuario GUI:" + secuenciaUsuarioGUI.toString());
comparaSecuencia();
generaSecuencia(); //Adds another value to the LinkedList
}
Compare code
public boolean comparaSecuencia(){
for (int i = 0; i < secuenciaSimon.size(); i++) {
//Here the pause should be
if(secuenciaSimon.get(i) != secuenciaUsuarioGUI.get(i)){
System.out.println("Not equal");
return false;
}
}
System.out.println("Equal");
puntuacion += 100; //Score
secuenciaUsuarioGUI.clear(); //Clears the LinkedList From the user
return true;
}
TL;DR Need to wait for "n" inputs of a button on a GUI before running more code without freezing the program.
Thanks