public Piece(int x, int y, Pieces type) { X = x; Y = y; Type = type; _colPiece = _pieces[(int)type]; Width = _colPiece.Width; Height = _colPiece.Height; }
public BitArray2D RotateRight() { var temp = new BitArray2D(Width, Height); for (int x = 0; x < Height; x++) { for (int y = 0; y < Width; y++) { temp.SetBit(x, y, _map[y, Width - x - 1]); } } return(temp); }
public void CreateBoard() { var board = new BitArray2D(TETRIS_WIDTH, TETRIS_HEIGHT); BoardPrettyPrint(); Console.WindowHeight = 23; Console.WindowWidth = 46; Console.BufferHeight = 23; Console.BufferWidth = 46; Console.WindowTop = 0; Console.CursorVisible = false; Console.SetCursorPosition(0, 0); }
public void RotateLeft() { var rotated = _colPiece.RotateLeft(); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { if (rotated[x, y]) { if (X + x >= Tetris.TETRIS_WIDTH || X + x < 0) { return; } } } } _colPiece = rotated; }
/// <summary> /// Creates the pieces on the console, from a text file. /// </summary> public static void CreatePieces() { /*This reads the size of the array and pieces from pieces.txt */ using (StringReader file = new StringReader(Resource.pieces)) { for (int piece = 0; piece < MAX_PIECE_TYPES; piece++) { int count = int.Parse(file.ReadLine()); _pieces[piece] = new BitArray2D(count, count); for (int line = 0; line < count; line++) { string temp = file.ReadLine(); for (int i = 0; i < temp.Length; i++) { _pieces[piece].SetBit(i, line, temp[i] == '1'); } } } } }