 | Code: // measures the offsets, in squares, from the center square for each orientation of each piece const short xyOffsets[PIECES][ROTATIONS][BLOCKS - 1][2] = { // O block { {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 0 {x, y} {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 1 {{-1, 0}, {-1, -1}, {0, -1}}, // orientation 2 {{-1, 0}, {-1, -1}, {0, -1}} // orientation 3 }, // I block { {{-2, 0}, {-1, 0}, {1, 0}}, // orientation 0 {{0, 1}, {0, -1}, {0, -2}}, // orientation 1 {{-2, 0}, {-1, 0}, {1, 0}}, // orientation 2 {{0, 1}, {0, -1}, {0, -2}} // orientation 3 }, // S block { {{-1, -1}, {0, -1}, {1, 0}}, // orientation 0 {{0, 1}, {1, 0}, {1, -1}}, // orientation 1 {{-1, -1}, {0, -1}, {1, 0}}, // orientation 2 {{0, 1}, {1, 0}, {1, -1}} // orientation 3 }, // Z block { {{-1, 0}, {0, -1}, {1, -1}}, // orientation 0 {{0, -1}, {1, 0}, {1, 1}}, // orientation 1 {{-1, 0}, {0, -1}, {1, -1}}, // orientation 2 {{0, -1}, {1, 0}, {1, 1}} // orientation 3 }, // L block { {{-1, -1}, {-1, 0}, {1, 0}}, // orientation 0 {{0, 1}, {0, -1}, {1, -1}}, // orientation 1 {{-1, 0}, {1, 0}, {1, 1}}, // orientation 2 {{-1, 1}, {0, 1}, {0, -1}} // orientation 3 }, // J block { {{-1, 0}, {1, 0}, {1, -1}}, // orientation 0 {{0, -1}, {0, 1}, {1, 1}}, // orientation 1 {{-1, 1}, {-1, 0}, {1, 0}}, // orientation 2 {{-1, -1}, {0, -1}, {0, 1}} // orientation 3 }, // T block { {{-1, 0}, {0, -1}, {1, 0}}, // orientation 0 {{0, -1}, {1, 0}, {0, 1}}, // orientation 1 {{-1, 0}, {0, 1}, {1, 0}}, // orientation 2 {{0, 1}, {-1, 0}, {0, -1}} // orientation 3 } };
|  |