@@ -17,7 +17,9 @@ int rRotating = 0;
1717int lRotating = 0 ;
1818int bRotating = 0 ;
1919
20- int animSpeed = 4 ;
20+ int animSpeed = 14 ;
21+
22+ int turnStack [10 ];
2123
2224FloppyCube DrawFloppyCube (FloppyCube floppyCube ){
2325 if (fRotating || rRotating || lRotating || bRotating ){
@@ -41,6 +43,14 @@ FloppyCube DrawFloppyCube(FloppyCube floppyCube){
4143 floppyCube = ExecuteTurn (floppyCube , B );
4244 bRotating = 0 ;
4345 }
46+
47+ if (turnStack [0 ] != 0 ){
48+ DoTurn (floppyCube , turnStack [0 ] - 1 );
49+
50+ for (int i = 1 ; i < 10 ; i ++ ){
51+ turnStack [i - 1 ] = turnStack [i ];
52+ }
53+ }
4454 }
4555 Vector2 planeSize = {1.85 , 1.85 };
4656
@@ -278,6 +288,18 @@ FloppyCube ExecuteTurn(FloppyCube cube, int turn){
278288}
279289
280290void DoTurn (FloppyCube cube , int turn ){
291+ if (fRotating || bRotating || rRotating || lRotating ){
292+ int stackLength = 0 ;
293+
294+ for (int i = 0 ; i < 10 ; i ++ ){
295+ if (turnStack [i ] != 0 ){
296+ stackLength = i + 1 ;
297+ }
298+ }
299+
300+ turnStack [stackLength ] = turn + 1 ;
301+ return ;
302+ }
281303 if (turn == F ){
282304 fRotating = 1 ;
283305 }
@@ -302,10 +324,37 @@ FloppyCube RandomScramble(FloppyCube cube){
302324 num = RandomRange (3 );
303325 }
304326
305- cube = ExecuteTurn (cube , num );
327+ DoTurn (cube , num );
306328
307329 previous = num ;
308330 }
309331
310332 return cube ;
333+ }
334+
335+ FloppyCube CloneFloppyCube (FloppyCube cube , FloppyCube clone ){
336+ CloneNumberArray (cube .topFace , 8 , clone .topFace );
337+ CloneNumberArray (cube .bottomFace , 8 , clone .bottomFace );
338+ CloneNumberArray (cube .rightFace , 3 , clone .rightFace );
339+ CloneNumberArray (cube .frontFace , 3 , clone .frontFace );
340+ CloneNumberArray (cube .leftFace , 3 , clone .leftFace );
341+ CloneNumberArray (cube .backFace , 3 , clone .backFace );
342+
343+ return clone ;
344+ }
345+
346+ bool IsCubeSolved (FloppyCube cube ){
347+ bool isSolved = true;
348+
349+ for (int i = 0 ; i < 8 ; i ++ ){
350+ if (cube .topFace [i ] != CWHITE ){
351+ isSolved = false;
352+ }
353+ }
354+
355+ if (cube .rightFace [0 ] != cube .rightFace [1 ]){
356+ isSolved = false;
357+ }
358+
359+ return isSolved ;
311360}
0 commit comments