public void UpdateGrid() { TetrominosTable.GetTetromino( (int)type, rotation, out grid, out sizeX, out sizeY, out int[] bounds ); this.boundsMinX = bounds[0]; this.boundsMinY = bounds[1]; this.boundsMaxX = bounds[2]; this.boundsMaxY = bounds[3]; }
public bool Rotate() { int rot = rotation; int[,] grid = null; int sizeX = 0; int sizeY = 0; int[] bounds = null; int posX = this.posX; int posY = this.posY; bool success = false; rot++; rot %= 4; TetrominosTable.GetTetromino( (int)type, rot, out grid, out sizeX, out sizeY, out bounds ); for (int i = 0; i < 5; i++) { TetrominosTable.GetWallKickOffset( (int)type, rot, i, out int offX, out int offY ); posX = this.posX + offX; posY = this.posY + offY; if (TestPosition( posX, posY, grid, sizeX, sizeY, bounds[0], bounds[1], bounds[2], bounds[3] )) { success = true; break; } } if (!success) { return(false); } this.posX = posX; this.posY = posY; this.rotation = rot; this.grid = grid; this.sizeX = sizeX; this.sizeY = sizeY; this.boundsMinX = bounds[0]; this.boundsMinY = bounds[1]; this.boundsMaxX = bounds[2]; this.boundsMaxY = bounds[3]; return(true); }