예제 #1
0
파일: Tetris1.cs 프로젝트: pixnek/tetris
    //Поворот фигуры
    void Rotate()
    {
        int[,] tmpFigure = figure.Rotate();
        int size = figure.GetSize();

        int[] coord = figure.GetCoord();
        int[,] tmpTable = new int[size, size];

        for (int y = coord [0]; y < coord [0] + size; y++)
        {
            for (int x = coord [1]; x < coord [1] + size; x++)
            {
                if ((y >= 0) && (y < heightTable) && (x >= 0) && (x < widthTable))
                {
                    tmpTable [y - coord [0], x - coord [1]] = table [y, x];
                    if (table [y, x] == 2)
                    {
                        return;
                    }
                }
                else
                {
                    if (tmpFigure [y - coord [0], x - coord [1]] != 0)
                    {
                        return;
                    }
                }
            }
        }

        for (int y = coord [0]; y < coord [0] + size; y++)
        {
            for (int x = coord [1]; x < coord [1] + size; x++)
            {
                if ((y >= 0) && (y < heightTable) && (x >= 0) && (x < widthTable))
                {
                    table [y, x] = tmpFigure [y - coord [0], x - coord [1]];
                }
            }
        }
        figure.SetFigure(tmpFigure);
    }
예제 #2
0
파일: Tetris1.cs 프로젝트: pixnek/tetris
    //Добавлене фигуры
    void AddFigure()
    {
        int n = RandomFigure();

        figure = mas[n];
        figure.Figure();
        n = figure.GetSize();
        int[] coord = figure.GetCoord();
        int[,] tmp       = new int[n, n];
        int[,] tmpFigure = figure.GetFigure();

        for (int y = coord [0]; y < coord [0] + n; y++)
        {
            for (int x = coord [1]; x < coord [1] + n; x++)
            {
                if (y >= 0)
                {
                    tmp [y - coord [0], x - coord [1]] = table [y, x];
                    if (tmpFigure [y - coord [0], x - coord [1]] > 0 && tmp [y - coord [0], x - coord [1]] == 2)
                    {
                        return;
                    }
                }
            }
        }

        for (int y = coord [0]; y < coord [0] + n; y++)
        {
            for (int x = coord [1]; x < coord [1] + n; x++)
            {
                if (y >= 0)
                {
                    table [y, x] = tmpFigure [y - coord [0], x - coord [1]];
                }
            }
        }
    }