Esempio n. 1
0
        public void RenderNext(int xMargin, int yMargin, Graphics graphics)
        {
            for (int x = 0; x < MatrixSize.Width; x++)
            {
                for (int y = 0; y < MatrixSize.Height; y++)
                {
                    if (!_tetrominoMatrix[x, y])
                    {
                        continue;
                    }
                    int xPosition = x;
                    int yPosition = y;
                    if (yPosition < 0)
                    {
                        continue;
                    }

                    xPosition *= TetrominoDrawing.SQUARE_SIZE;
                    yPosition *= TetrominoDrawing.SQUARE_SIZE;

                    xPosition += xMargin;
                    yPosition += yMargin;

                    TetrominoDrawing tetrominoDrawing = TetrominoDrawing.GetTetrominoColors(TetrominoType);
                    graphics.FillRectangle(new SolidBrush(tetrominoDrawing.FillColor),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                    graphics.DrawRectangle(new Pen(tetrominoDrawing.BorderColor, TetrominoDrawing.SQUARE_BORDER),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                }
            }
        }
Esempio n. 2
0
        public void Render(Graphics graphics)
        {
            for (int x = 0; x < MatrixSize.Width; x++)
            {
                for (int y = 0; y < MatrixSize.Height; y++)
                {
                    if (!_tetrominoMatrix[x, y])
                    {
                        continue;
                    }
                    int xPosition = x + _xIncrease;
                    int yPosition = y + _yIncrease;
                    if (yPosition < 0)
                    {
                        continue;
                    }

                    xPosition *= TetrominoDrawing.SQUARE_SIZE;
                    yPosition *= TetrominoDrawing.SQUARE_SIZE;

                    xPosition += TetrisLevel.XMARGIN;
                    yPosition += TetrisLevel.YMARGIN;

                    TetrominoDrawing tetrominoDrawing = TetrominoDrawing.GetTetrominoColors(TetrominoType);
                    graphics.FillRectangle(new SolidBrush(tetrominoDrawing.FillColor),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                    graphics.DrawRectangle(new Pen(tetrominoDrawing.BorderColor, TetrominoDrawing.SQUARE_BORDER),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                }
            }
        }
Esempio n. 3
0
        public static TetrominoDrawing GetTetrominoColors(TetrominoType tetrominoType)
        {
            TetrominoDrawing tetrominoDrawing = new TetrominoDrawing();

            switch (tetrominoType)
            {
            case TetrominoType.I:
                tetrominoDrawing.FillColor   = Color.Cyan;
                tetrominoDrawing.BorderColor = Color.LightCyan;
                return(tetrominoDrawing);

            case TetrominoType.J:
                tetrominoDrawing.FillColor   = Color.Blue;
                tetrominoDrawing.BorderColor = Color.LightBlue;
                return(tetrominoDrawing);

            case TetrominoType.L:
                tetrominoDrawing.FillColor   = Color.OrangeRed;
                tetrominoDrawing.BorderColor = Color.Orange;
                return(tetrominoDrawing);

            case TetrominoType.O:
                tetrominoDrawing.FillColor   = Color.Yellow;
                tetrominoDrawing.BorderColor = Color.White;
                return(tetrominoDrawing);

            case TetrominoType.S:
                tetrominoDrawing.FillColor   = Color.Green;
                tetrominoDrawing.BorderColor = Color.LightGreen;
                return(tetrominoDrawing);

            case TetrominoType.T:
                tetrominoDrawing.FillColor   = Color.Purple;
                tetrominoDrawing.BorderColor = Color.Orchid;
                return(tetrominoDrawing);

            case TetrominoType.Z:
                tetrominoDrawing.FillColor   = Color.Red;
                tetrominoDrawing.BorderColor = Color.LightCoral;
                return(tetrominoDrawing);

            case TetrominoType.Filled:
                tetrominoDrawing.FillColor   = Color.LightGray;
                tetrominoDrawing.BorderColor = Color.White;
                return(tetrominoDrawing);

            default:
            case TetrominoType.Empty:
                tetrominoDrawing.FillColor   = Color.Black;
                tetrominoDrawing.BorderColor = Color.FromArgb(12, 29, 43);
                return(tetrominoDrawing);
            }
        }
Esempio n. 4
0
        private void RenderNextTetromino(Graphics graphics)
        {
            graphics.DrawRectangle(new Pen(Color.White, TetrominoDrawing.SQUARE_BORDER),
                                   new Rectangle((LevelSize.Width * TetrominoDrawing.SQUARE_SIZE) + (2 * XMARGIN),
                                                 YMARGIN,
                                                 TetrominoDrawing.SQUARE_SIZE * 4,
                                                 TetrominoDrawing.SQUARE_SIZE));

            for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 4; y++)
                {
                    int xPosition = x;
                    int yPosition = y;

                    xPosition *= TetrominoDrawing.SQUARE_SIZE;
                    yPosition *= TetrominoDrawing.SQUARE_SIZE;

                    xPosition += (LevelSize.Width * TetrominoDrawing.SQUARE_SIZE) + (2 * XMARGIN);
                    yPosition += YMARGIN + TetrominoDrawing.SQUARE_SIZE;

                    TetrominoDrawing tetrominoDrawing = TetrominoDrawing.GetTetrominoColors(TetrominoType.Empty);
                    graphics.FillRectangle(new SolidBrush(tetrominoDrawing.FillColor),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                    graphics.DrawRectangle(new Pen(tetrominoDrawing.BorderColor, TetrominoDrawing.SQUARE_BORDER),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                }
            }

            graphics.DrawRectangle(new Pen(Color.White, TetrominoDrawing.SQUARE_BORDER),
                                   new Rectangle((LevelSize.Width * TetrominoDrawing.SQUARE_SIZE) + (2 * XMARGIN),
                                                 YMARGIN + TetrominoDrawing.SQUARE_SIZE,
                                                 TetrominoDrawing.SQUARE_SIZE * 4,
                                                 TetrominoDrawing.SQUARE_SIZE * 4));

            NextTetromino.RenderNext((LevelSize.Width * TetrominoDrawing.SQUARE_SIZE) + (2 * XMARGIN),
                                     YMARGIN + TetrominoDrawing.SQUARE_SIZE,
                                     graphics);

            Font font = new Font(FontFamily.GenericSansSerif, 12);

            graphics.DrawString("NEXT:",
                                font,
                                new SolidBrush(Color.White),
                                new Point((LevelSize.Width * TetrominoDrawing.SQUARE_SIZE) + (2 * XMARGIN), YMARGIN));
        }
Esempio n. 5
0
        private void RenderTetrisCanvas(Graphics graphics)
        {
            for (int x = 0; x < LevelSize.Width; x++)
            {
                for (int y = 0; y < LevelSize.Height; y++)
                {
                    int xPosition = (x * TetrominoDrawing.SQUARE_SIZE) + TetrisLevel.XMARGIN;
                    int yPosition = (y * TetrominoDrawing.SQUARE_SIZE) + TetrisLevel.YMARGIN;

                    TetrominoDrawing tetrominoDrawing = TetrominoDrawing.GetTetrominoColors(LevelMatrix[y][x]);
                    graphics.FillRectangle(new SolidBrush(tetrominoDrawing.FillColor),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                    graphics.DrawRectangle(new Pen(tetrominoDrawing.BorderColor, TetrominoDrawing.SQUARE_BORDER),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                }
            }

            for (int x = 0; x < LevelSize.Width; x++)
            {
                for (int y = 0; y < LevelSize.Height; y++)
                {
                    if (LevelMatrix[y][x] == TetrominoType.Empty)
                    {
                        continue;
                    }

                    int xPosition = (x * TetrominoDrawing.SQUARE_SIZE) + TetrisLevel.XMARGIN;
                    int yPosition = (y * TetrominoDrawing.SQUARE_SIZE) + TetrisLevel.YMARGIN;

                    TetrominoDrawing tetrominoDrawing = TetrominoDrawing.GetTetrominoColors(TetrominoType.Filled);
                    graphics.FillRectangle(new SolidBrush(Color.LightGray),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                    graphics.DrawRectangle(new Pen(Color.White, TetrominoDrawing.SQUARE_BORDER),
                                           new Rectangle(xPosition, yPosition, TetrominoDrawing.SQUARE_SIZE, TetrominoDrawing.SQUARE_SIZE));
                }
            }

            ActiveTetromino.Render(graphics);
        }