public Globals.coords getHardDrop(int[,] shape, Globals.coords location) { do { location.y++; } while (checkPiece(shape, location)); location.y--; return location; }
public bool placePiece(int[,] shape, Globals.coords location) { //adds the tetronimo object to the field array //similar to checkPiece, this performs the actual write int tempX = location.x; for (int i = 0; i < Globals.PIECE_HEIGHT; i++) { //checking to see if there's a row if (shape[i, 0] + shape[i, 1] + shape[i, 2] + shape[i, 3] > 0) { for (int j = 0; j < Globals.PIECE_WIDTH; j++) { //checking to see if there's a shape to draw, and there's nothing in the way if (shape[i, j] > 0) { if (field[location.y, tempX] == 0) { field[location.y, tempX] = shape[i, j]; } else { return false; } } tempX++; } location.y++; tempX = location.x; } else { location.y++; } } return true; }
public bool checkPiece(int[,] shape, Globals.coords location) { int tempX = location.x; int tempY = location.y; //collision/bounds checking for (int i = 0; i < Globals.PIECE_HEIGHT; i++) { //checking to see if there's a row if (shape[i, 0] + shape[i, 1] + shape[i, 2] + shape[i, 3] > 0) { for (int j = 0; j < Globals.PIECE_WIDTH; j++) { //checking to see if there's a shape to draw, and there's nothing in the way if (shape[i, j] > 0) { if (field[tempY, tempX] > 0) { return false; } } tempX++; } tempY++; tempX = location.x; } else { tempY++; } } return true; }