c言語 テトリス作成 回転(SRS)の実装

rotate.c

1// Iミノの回転処理 2bool RotateRightI(GameState *game, Block *block) 3{ 4 if (CanRotate(game, block, true, -2, 0)) 5 return RotateRight(game, block, 0, 0); 6 7 if (block->angle == Angle0) 8 { 9 if (CanRotate(game, block, true, -2, 0)) 10 return RotateRight(game, block, -2, 0); 11 if (CanRotate(game, block, true, 1, 0)) 12 return RotateRight(game, block, 1, 0); 13 if (CanRotate(game, block, true, -2, 1)) 14 return RotateRight(game, block, -2, 1); 15 if (CanRotate(game, block, true, 1, -2)) 16 return RotateRight(game, block, 1, -2); 17 } 18 else if (block->angle == Angle90) 19 { 20 if (CanRotate(game, block, true, -1, 0)) 21 return RotateRight(game, block, -1, 0); 22 if (CanRotate(game, block, true, 2, 0)) 23 return RotateRight(game, block, 2, 0); 24 if (CanRotate(game, block, true, -1, -2)) 25 return RotateRight(game, block, -1, -2); 26 if (CanRotate(game, block, true, 2, 1)) 27 return RotateRight(game, block, 2, 1); 28 } 29 else if (block->angle == Angle180) 30 { 31 if (CanRotate(game, block, true, 2, 0)) 32 return RotateRight(game, block, 2, 0); 33 if (CanRotate(game, block, true, -1, 0)) 34 return RotateRight(game, block, -1, 0); 35 if (CanRotate(game, block, true, 2, -1)) 36 return RotateRight(game, block, 2, -1); 37 if (CanRotate(game, block, true, -1, 2)) 38 return RotateRight(game, block, -1, 2); 39 } 40 else if (block->angle == Angle270) 41 { 42 if (CanRotate(game, block, true, -2, 0)) 43 return RotateRight(game, block, -2, 0); 44 if (CanRotate(game, block, true, 1, 0)) 45 return RotateRight(game, block, 1, 0); 46 if (CanRotate(game, block, true, 1, 2)) 47 return RotateRight(game, block, 1, 2); 48 if (CanRotate(game, block, true, -2, -1)) 49 return RotateRight(game, block, -2, -1); 50 } 51 return false; 52} 53 54// I,O以外の回転処理 55bool RotateRight3(GameState *game, Block *block) 56{ 57 if (CanRotate(game, block, true, 0, 0)) 58 return RotateRight(game, block, 0, 0); 59 60 if (block->angle == Angle0) 61 { 62 if (CanRotate(game, block, true, -1, 0)) 63 return RotateRight(game, block, -1, 0); 64 if (CanRotate(game, block, true, -1, -1)) 65 return RotateRight(game, block, -1, -1); 66 if (CanRotate(game, block, true, 0, 2)) 67 return RotateRight(game, block, 0, 2); 68 if (CanRotate(game, block, true, -1, 2)) 69 return RotateRight(game, block, -1, 2); 70 } 71 else if (block->angle == Angle90) 72 { 73 if (CanRotate(game, block, true, 1, 0)) 74 return RotateRight(game, block, 1, 0); 75 if (CanRotate(game, block, true, 1, 1)) 76 return RotateRight(game, block, 1, 1); 77 if (CanRotate(game, block, true, 0, -2)) 78 return RotateRight(game, block, 0, -2); 79 if (CanRotate(game, block, true, 1, -2)) 80 return RotateRight(game, block, 1, -2); 81 } 82 else if (block->angle == Angle180) 83 { 84 if (CanRotate(game, block, true, 1, 0)) 85 return RotateRight(game, block, 1, 0); 86 if (CanRotate(game, block, true, 1, -1)) 87 return RotateRight(game, block, 1, -1); 88 if (CanRotate(game, block, true, 0, 2)) 89 return RotateRight(game, block, 0, 2); 90 if (CanRotate(game, block, true, 1, 2)) 91 return RotateRight(game, block, 1, 2); 92 } 93 else if (block->angle == Angle270) 94 { 95 if (CanRotate(game, block, true, -2, 0)) 96 return RotateRight(game, block, -2, 0); 97 if (CanRotate(game, block, true, -2, 1)) 98 return RotateRight(game, block, -2, 1); 99 if (CanRotate(game, block, true, 0, -2)) 100 return RotateRight(game, block, 0, -2); 101 if (CanRotate(game, block, true, -1, -2)) 102 return RotateRight(game, block, -1, -2); 103 } 104 return false; 105} 106

コメントを投稿

0 コメント