Esempio n. 1
0
        static Block Rotate(Block inp)
        {
            if (inp.blockCols != inp.blockRows) // If it's The O-Tetrimino there's no sence in rotating it
            {
                inp.Clear();
                int[,] newBlock = GenerateRotatedBlockData(inp);
                Block jnp = new Block(inp.blockPositionX, inp.blockPositionY, newBlock);

                //// Try to move the block a bit so it can be rotated. Only valid for the I-Tetrimino!
                //if (Block.OverlapBlocks(jnp, bigBlock))
                //{
                //    if (jnp.blockCols > 3)
                //    {
                //        jnp.blockPositionX = jnp.blockPositionX - 2; ;
                //    }
                //}

                if (Block.OverlapBlocks(jnp, bigBlock))
                {
                    inp.Print();
                    return(inp);
                }
                else
                {
                    Sounds.SFX(Sounds.SoundEffects.Move);
                    jnp.Print();
                    return(jnp);
                }
            }
            return(inp);
        }
Esempio n. 2
0
        static void Drop(Block inp)
        {
            while (Block.OverlapBlocks(inp, bigBlock) == false)
            {
                score += level * 2; // Bonus score

                inp.blockPositionY++;
                if (Block.OverlapBlocks(inp, bigBlock) == true)
                {
                    inp.blockPositionY--;
                    //brickPlayer1 = GenerateRandomBlock();
                    brickPlayer1 = nextBrick;
                    bigBlock     = bigBlock + inp;
                    nextBrick    = GenerateRandomBlock(PlayerStartPosition.PlayerOne);
                    PrintNextBrick();
                }
                else
                {
                    inp.blockPositionY--;
                    inp.Clear();
                    inp.blockPositionY++;
                    inp.Print();
                    Sounds.SFX(Sounds.SoundEffects.Move);
                }
            }
        }
Esempio n. 3
0
 public static void HideBlock()
 {
     if (ShiftBlock.info != null)
     {
         FirstBlock.Clear();
         Block temp = new Block();
         AssignBlock(temp, FirstBlock);
         AssignBlock(FirstBlock, ShiftBlock);
         AssignBlock(ShiftBlock, temp);
         ShiftBlock.SetBlockType();
         NextBlock.SetBlockType();
     }
     else
     {
         FirstBlock.Clear();
         AssignBlock(ShiftBlock, FirstBlock);
         AssignBlock(FirstBlock, NextBlock);
         NextBlock = GenerateBlock();
         ShiftBlock.SetBlockType();
         NextBlock.SetBlockType();
     }
 }
Esempio n. 4
0
 static void ClearRow(int row)
 {
     bigBlock.Clear();
     for (int i = row; i > 0; i--)
     {
         for (int col = 1; col < 15; col++)
         {
             bigBlock[col, i] = bigBlock[col, i - 1];
         }
     }
     Sounds.SFX(Sounds.SoundEffects.ClearLine);
     bigBlock.Print();
 }
Esempio n. 5
0
        static void Right(Block inp)
        {
            inp.blockPositionX++;

            if (Block.OverlapBlocks(inp, bigBlock))
            {
                inp.blockPositionX--;
            }
            else
            {
                inp.blockPositionX--;
                inp.Clear();
                inp.blockPositionX++;
                inp.Print();
                Sounds.SFX(Sounds.SoundEffects.Move);
            }
        }
Esempio n. 6
0
        static Block Rotate(Block inp)
        {
            if (inp.blockCols != inp.blockRows) // If it's The O-Tetrimino there's no sence in rotating it
            {
                inp.Clear();
                Block newBlock = inp.Rotate();

                if (Block.OverlapBlocks(newBlock, bigBlock))
                {
                    inp.Print();
                    return(inp);
                }
                else
                {
                    newBlock.Print();
                    Sounds.SFX(Sounds.SoundEffects.Rotate);
                    return(newBlock);
                }
            }
            return(inp);
        }
Esempio n. 7
0
        static void Down(Block inp)
        {
            inp.blockPositionY++;

            if (Block.OverlapBlocks(inp, bigBlock))
            {
                inp.blockPositionY--;
                //brickPlayer1 = GenerateRandomBlock();
                brickPlayer1 = nextBrick;
                brickPlayer1.Print();
                bigBlock  = bigBlock + inp;
                nextBrick = GenerateRandomBlock(PlayerStartPosition.PlayerOne);
                PrintNextBrick();
            }
            else
            {
                inp.blockPositionY--;
                inp.Clear();
                inp.blockPositionY++;
                inp.Print();
                Sounds.SFX(Sounds.SoundEffects.Move);
            }
        }
Esempio n. 8
0
        static Block Rotate(Block inp)
        {
            if (inp.blockCols != inp.blockRows) // If it's The O-Tetrimino there's no sence in rotating it
            {
                inp.Clear();
                Block newBlock = inp.Rotate();

                if (Block.OverlapBlocks(newBlock, bigBlock))
                {
                    inp.Print();
                    return inp;
                }
                else
                {
                    newBlock.Print();
                    Sounds.SFX(Sounds.SoundEffects.Rotate);
                    return newBlock;
                }
            }
            return inp;
        }