Example #1
0
    public void Merge(GameTime gameTime)
    {
        int x = tetrisblock.tetrisblock.GetLength(0);

        for (int a = 0; a < x; a++)
        {
            for (int k = 0; k < x; k++)
            {
                int gridX = tetrisblock.blockposition.X / blocksize + a;
                int gridY = tetrisblock.blockposition.Y / blocksize + k;
                if (tetrisblock.tetrisblock[a, k] != 0 && tetrisblock.tetrisblock[a, k] != 8)
                {
                    grid.grid[gridX, gridY] = tetrisblock.tetrisblock[a, k];
                }
                if (tetrisblock.tetrisblock[a, k] == 8)
                {
                    Explode(gridX, gridY);
                }
            }
        }
        if (GameOver())
        {
            gameState = GameState.GameOver;
        }
        tetrisblock = nextTetrisBlock;
        tetrisblock.blockposition = new Point(4 * blocksize, 0);
        fall.Play(0.2f, 0, 0);
        grid.DetectFullLine();
        NextLevel(gameTime);
        GenerateRandomBlock();
    }