piece.c (1263B)
1 #include <stdbool.h> 2 3 #include "piece.h" 4 5 /* This was defined in the tetris guidelines */ 6 const bool piece_occupancy[PIECE_CNT][ROTATION_CNT][9] = { 7 {}, 8 { /* O */ 9 {0,1,1, 10 0,1,1, 11 0,0,0}, 12 {0,1,1, 13 0,1,1, 14 0,0,0}, 15 {0,1,1, 16 0,1,1, 17 0,0,0}, 18 {0,1,1, 19 0,1,1, 20 0,0,0}, 21 }, { /* I doesnt go in this because it is 4 wide */ 22 }, { /* T */ 23 {0,1,0, 24 1,1,1, 25 0,0,0}, 26 {0,1,0, 27 0,1,1, 28 0,1,0}, 29 {0,0,0, 30 1,1,1, 31 0,1,0}, 32 {0,1,0, 33 1,1,0, 34 0,1,0}, 35 }, { /* L */ 36 {0,0,1, 37 1,1,1, 38 0,0,0}, 39 {0,1,0, 40 0,1,0, 41 0,1,1}, 42 {0,0,0, 43 1,1,1, 44 1,0,0}, 45 {1,1,0, 46 0,1,0, 47 0,1,0} 48 }, { /* J */ 49 {1,0,0, 50 1,1,1, 51 0,0,0}, 52 {0,1,1, 53 0,1,0, 54 0,1,0}, 55 {0,0,0, 56 1,1,1, 57 0,0,1}, 58 {0,1,0, 59 0,1,0, 60 1,1,0} 61 }, { /* S */ 62 {0,1,1, 63 1,1,0, 64 0,0,0}, 65 {0,1,0, 66 0,1,1, 67 0,0,1}, 68 {0,0,0, 69 0,1,1, 70 1,1,0}, 71 {1,0,0, 72 1,1,0, 73 0,1,0} 74 }, { /* Z */ 75 {1,1,0, 76 0,1,1, 77 0,0,0}, 78 {0,0,1, 79 0,1,1, 80 0,1,0}, 81 {0,0,0, 82 1,1,0, 83 0,1,1}, 84 {0,1,0, 85 1,1,0, 86 1,0,0} 87 } 88 }; 89 90 const bool I_occupancy[ROTATION_CNT][16] = { 91 {0,0,0,0, 92 1,1,1,1, 93 0,0,0,0, 94 0,0,0,0}, 95 {0,0,1,0, 96 0,0,1,0, 97 0,0,1,0, 98 0,0,1,0}, 99 {0,0,0,0, 100 0,0,0,0, 101 1,1,1,1, 102 0,0,0,0}, 103 {0,1,0,0, 104 0,1,0,0, 105 0,1,0,0, 106 0,1,0,0}, 107 };