protected Tetromino(Tetromino t2) { this.shape[0] = t2.shape[0]; this.shape[1] = t2.shape[1]; this.shape[2] = t2.shape[2]; this.shape[3] = t2.shape[3]; }
private void SetupNewGame() { dropDownTimer.Enabled = false; dropDownTimer.Interval = DEFAULT_DROPDOWN_INTERVAL; level = 0; rows = 0; points = 0; pointsLabel.Text = "0"; levelLabel.Text = "0"; linesLabel.Text = "0"; paused = false; pauseButton.Text = "Pause"; pos = new Point(new Random().Next(COLS - 1) + 1, START_Y); tetFact = new TetrominoFactory(); if (futureShapes.Count > 0) { futureShapes.Clear(); } FillMovesQueue(); tet = futureShapes.Dequeue(); InitializeGrid(); moveTetrimino(pos); }
private void lockShapeInGrid() { checkForCompleteRows(); if (hasPlayerLost()) { dropDownTimer.Stop(); backgroundThemePlayer.controls.stop(); stopGame(); MessageBox.Show("YOU LOSE!"); } else { tet = futureShapes.Dequeue(); pos = new Point(new Random().Next(1, COLS - 1), START_Y); if (futureShapes.Count < REFILL_QUEUE_THRESHOLD) { FillMovesQueue(); } updateShapePreview(); } tetrisPanel.Invalidate(); }
private void previewShapePanel_Paint(object sender, PaintEventArgs e) { ControlPaint.DrawBorder(e.Graphics, this.previewShapePanel.ClientRectangle, Color.WhiteSmoke, ButtonBorderStyle.Solid); if (futureShapes.Count >= 1 && gamePlaying) { int xBase = previewShapePanel.Width / 2 - BOX_WIDTH / 2; int yBase = previewShapePanel.Height / 2 - BOX_HEIGHT / 2; Tetromino nextShape = futureShapes.Peek(); foreach (Point p in nextShape.Shape) { int x = xBase + p.X * BOX_WIDTH; int y = yBase + p.Y * BOX_WIDTH; //fill the shape e.Graphics.FillRectangle(nextShape.FillBrush, xBase + p.X * BOX_WIDTH, yBase + p.Y * BOX_WIDTH, BOX_WIDTH, BOX_HEIGHT); //draw the border e.Graphics.DrawRectangle(nextShape.BorderPen, xBase + p.X * BOX_WIDTH, yBase + p.Y * BOX_WIDTH, BOX_WIDTH, BOX_HEIGHT); } } }
private void SetupNewGame() { dropDownTimer.Enabled = false; dropDownTimer.Interval = DEFAULT_DROPDOWN_INTERVAL; level = 0; rows = 0; points = 0; pointsLabel.Text = "0"; levelLabel.Text = "0"; linesLabel.Text = "0"; paused = false; pauseButton.Text = "Pause"; pos = new Point(new Random().Next(COLS - 1) + 1, START_Y); tetFact = new TetrominoFactory(); if (futureShapes.Count > 0) futureShapes.Clear(); FillMovesQueue(); tet = futureShapes.Dequeue(); InitializeGrid(); moveTetrimino(pos); }
private void lockShapeInGrid() { checkForCompleteRows(); if (hasPlayerLost()) { dropDownTimer.Stop(); backgroundThemePlayer.controls.stop(); stopGame(); MessageBox.Show("YOU LOSE!"); } else { tet = futureShapes.Dequeue(); pos = new Point(new Random().Next(1, COLS - 1), START_Y); if (futureShapes.Count < REFILL_QUEUE_THRESHOLD) FillMovesQueue(); updateShapePreview(); } tetrisPanel.Invalidate(); }