/// <summary> /// Creates a new instance of TetrisBoard. /// </summary> public TetrisBoard(TetrisWindow form) { tetrisBlockMatrix = new TetrisBlock[16, 22]; tetrisBlockMatrix.Initialize (); r = new Random (); this.form = form; }
/// <summary> /// Construct a new O Shaped Tetrinimo. /// </summary> /// <param name="matrix">Please pass the matrix field of the TetrisBoard object.</param> public OShapedTetrimino(TetrisBlock[,] matrix, TetrisWindow form) : base(matrix, form) { blocks = new List<TetrisBlock> () { new TetrisBlock (Color.Cyan, 7, 0, form), new TetrisBlock (Color.Cyan, 7, 1,form), new TetrisBlock (Color.Cyan, 8, 0, form), new TetrisBlock (Color.Cyan, 8, 1, form) }; }
/// <summary> /// Constructs a new L shaped tetrimino. /// </summary> /// <param name="matrix">Please pass the matrix field of the TetrisBoard object.</param> public LShapedTetrimino(int rotationIndex, TetrisBlock[,] matrix, TetrisWindow form) : base(matrix, form) { blocks = new List<TetrisBlock> () { new TetrisBlock (Color.Yellow, 7, 0, form), new TetrisBlock (Color.Yellow, 7, 1, form), new TetrisBlock (Color.Yellow, 7, 2, form), new TetrisBlock (Color.Yellow, 8, 2, form) }; RotationIndex = 0; for (int i = 0 ; i < rotationIndex ; i++) { Rotate (); } }
/// <summary> /// Creates a new instance of TetrisBlock. /// </summary> /// <param name="color">The color of the block.</param> /// <param name="picture">The picture box corresponding to the block.</param> public TetrisBlock(Color color, int x, int y, TetrisWindow form) { picture = new PictureBox (); timer = new System.Windows.Forms.Timer () { Interval = 1 }; timer.Tick += OnTimerTick; Color = color; X = x; Y = y; picture.Name = "TetrisBlock"; picture.Size = new Size (20, 20); picture.SizeMode = PictureBoxSizeMode.Zoom; picture.Image = Resources.tetrisBlock; picture.Visible = true; form.panel1.Controls.Add (picture); this.form = form; timer.Start (); }
/// <summary> /// Constructs a new S shaped tetrimino. /// </summary> /// <param name="matrix">Please pass the matrix field of the TetrisBoard object.</param> public SShapedTetrimino(int rotationIndex, TetrisBlock[,] matrix, TetrisWindow form) : base(matrix, form) { if (rotationIndex == 0) { blocks = new List<TetrisBlock> () { new TetrisBlock (Color.Lime, 6, 1, form), new TetrisBlock (Color.Lime, 7, 1, form), new TetrisBlock (Color.Lime, 7, 0, form), new TetrisBlock (Color.Lime, 8, 0, form) }; } else if (rotationIndex == 1) { blocks = new List<TetrisBlock> () { new TetrisBlock (Color.Lime, 7, 0, form), new TetrisBlock (Color.Lime, 7, 1, form), new TetrisBlock (Color.Lime, 8, 1, form), new TetrisBlock (Color.Lime, 8, 2, form) }; } RotationIndex = rotationIndex; }
protected Tetrimino(TetrisBlock[,] matrix, TetrisWindow form) { tetrisBlockMatrix = matrix; timer = new Timer () { Interval = 1000, Enabled = true }; timer.Tick += timer_Elapsed; }