I am currently creating a rubiks cube project for my a level NEA and currently the cube solves itself so I am now focusing on the implementation of the cube. I have got to a stage where i have a cube made up of 26 different cubes to allow me to give each face smooth rotations and nice colours. I have the code for one of the face rotations below. The left face to be exact but you do not need to know that.
for (int i = 0; i < 90; i++)
{
cube[0].rotateX(Math.PI / 360); // uses math.PI because the rotations are in radians
cube[1].rotateX(Math.PI / 360); // each of these commands rotate 1 degree
cube[2].rotateX(Math.PI / 360);
cube[9].rotateX(Math.PI / 360);
cube[10].rotateX(Math.PI / 360);
cube[11].rotateX(Math.PI / 360);
cube[17].rotateX(Math.PI / 360);
cube[18].rotateX(Math.PI / 360);
cube[19].rotateX(Math.PI / 360);
Invalidate(); // runs the paint function again to redraw the cube but rotated
}
This code performs one 90 degree turn of the face but what I would like to know is why doesn't it update the cube with the invalidate command on each iteration of the for loop and instead only does it once after the turn is performed. And is there a way to make it update on every iteration so I can get a nice smooth turn of the face.
Thanks in advance.