Hello! So I am trying to design a Rubik’s cube in jMonkey, and I wanted to add a feature to randomize the cube. I made and attached the input manager, and I have a function that looks like
long start = System.currentTimeMillis();
long update = System.currentTimeMillis();
Random rand = new Random();
while(update-start<5*1000){
update = System.currentTimeMillis();
if(angSum>max){
int randNum = rand.nextInt(6)+1;
rotate.onAction("Rotate"+randNum, false, tpf);
angSum = 0;
}
update(tpf);
}`
Where rotate
is an ActionListener that handles when a user wants to rotate a specific way “Rotate1”, “Rotate2”, etc. and update is the standard update loop that rotates a side of the cube. When this is run the screen freezes, so is there any way I can update the screen from within this loop? Or is there a better way of achieving randomization?
Thank you!