Esempio n. 1
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. 2
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. 3
0
        static void Down(int playerNumber)
        {
            brickPlayer[playerNumber].blockPositionY++;

            if (numberOfPlayers == 2 && Block.OverlapBlocks(brickPlayer[1], brickPlayer[0]))
            {
                brickPlayer[playerNumber].blockPositionY--;
            }
            else if (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock))
            {
                brickPlayer[playerNumber].blockPositionY--;
                bigBlock = bigBlock + brickPlayer[playerNumber];
                brickPlayer[playerNumber] = nextBrick.Clone();
                brickPlayer[playerNumber].blockPositionX = playerPos[playerNumber];
                brickPlayer[playerNumber].Print();
                CheckForCompleteLines();
                nextBrick = GenerateRandomBlock(playerPos[playerNumber]);
                PrintNextBrick();
                bigBlock.SetColor(15);
                bigBlock.Print();
            }
            else
            {
                brickPlayer[playerNumber].blockPositionY--;
                brickPlayer[playerNumber].Clear();
                Sounds.SFX(Sounds.SoundEffects.Move);
                brickPlayer[playerNumber].blockPositionY++;
                brickPlayer[playerNumber].Print();
            }
        }
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 Gameover(Block inp)
 {
     if (Block.OverlapBlocks(inp, bigBlock) == true)
     {
         if (bigBlock.blockRows == Console.WindowHeight)
         {
             Console.BackgroundColor = ConsoleColor.Red;
             Sounds.SFX(Sounds.SoundEffects.GameOver);
             PrintOnPosition(12, 12, "Game Over!");
             Thread.Sleep(2000);
             Main();
         }
     }
 }
Esempio n. 6
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. 7
0
        static void Right(int playerNumber)
        {
            brickPlayer[playerNumber].blockPositionX++;

            if ((numberOfPlayers == 1 && Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock)) ||
                (numberOfPlayers == 2 && Block.OverlapBlocks(brickPlayer[1], brickPlayer[0], bigBlock)))
            {
                brickPlayer[playerNumber].blockPositionX--;
            }
            else
            {
                brickPlayer[playerNumber].blockPositionX--;
                brickPlayer[playerNumber].Clear();
                brickPlayer[playerNumber].blockPositionX++;
                brickPlayer[playerNumber].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);
        }
Esempio n. 9
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. 10
0
 static void Drop(int playerNumber)
 {
     if (numberOfPlayers == 2)
     {
         if (brickPlayer[playerNumber].blockPositionY > brickPlayer[Math.Abs(playerNumber - 1)].blockPositionY)
         {
             while (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == false)
             {
                 score += level * 2; // Bonus score
                 brickPlayer[playerNumber].blockPositionY++;
                 if (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == true)
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     bigBlock = bigBlock + brickPlayer[playerNumber];
                     brickPlayer[playerNumber] = nextBrick;
                     brickPlayer[playerNumber].blockPositionX = playerPos[playerNumber];
                     brickPlayer[playerNumber].Print();
                     CheckForCompleteLines();
                     nextBrick = GenerateRandomBlock(playerPos[0]);
                     Sounds.SFX(Sounds.SoundEffects.Drop);
                     PrintNextBrick();
                     bigBlock.SetColor(15);
                     bigBlock.Print();
                     return;
                 }
                 else
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     brickPlayer[playerNumber].Clear();
                     brickPlayer[playerNumber].blockPositionY++;
                     brickPlayer[playerNumber].Print();
                 }
             }
         }
         else if (brickPlayer[playerNumber].blockPositionX > brickPlayer[Math.Abs(playerNumber - 1)].blockPositionX + brickPlayer[Math.Abs(playerNumber - 1)].blockCols - 1 || brickPlayer[playerNumber].blockPositionX + brickPlayer[playerNumber].blockCols - 1 < brickPlayer[Math.Abs(playerNumber - 1)].blockPositionX)
         {
             while (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == false)
             {
                 score += level * 2; // Bonus score
                 brickPlayer[playerNumber].blockPositionY++;
                 if (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == true)
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     bigBlock = bigBlock + brickPlayer[playerNumber];
                     brickPlayer[playerNumber] = nextBrick;
                     brickPlayer[playerNumber].blockPositionX = playerPos[playerNumber];
                     brickPlayer[playerNumber].Print();
                     CheckForCompleteLines();
                     nextBrick = GenerateRandomBlock(playerPos[0]);
                     Sounds.SFX(Sounds.SoundEffects.Drop);
                     PrintNextBrick();
                     bigBlock.SetColor(15);
                     bigBlock.Print();
                     return;
                 }
                 else
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     brickPlayer[playerNumber].Clear();
                     brickPlayer[playerNumber].blockPositionY++;
                     brickPlayer[playerNumber].Print();
                 }
             }
         }
     }
     else
     {
         while (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == false)
         {
             score += level * 2; // Bonus score
             brickPlayer[playerNumber].blockPositionY++;
             if (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == true)
             {
                 brickPlayer[playerNumber].blockPositionY--;
                 bigBlock = bigBlock + brickPlayer[playerNumber];
                 brickPlayer[playerNumber] = nextBrick;
                 brickPlayer[playerNumber].blockPositionX = playerPos[playerNumber];
                 brickPlayer[playerNumber].Print();
                 CheckForCompleteLines();
                 nextBrick = GenerateRandomBlock(playerPos[0]);
                 Sounds.SFX(Sounds.SoundEffects.Drop);
                 PrintNextBrick();
                 bigBlock.SetColor(15);
                 bigBlock.Print();
                 return;
             }
             else
             {
                 brickPlayer[playerNumber].blockPositionY--;
                 brickPlayer[playerNumber].Clear();
                 brickPlayer[playerNumber].blockPositionY++;
                 brickPlayer[playerNumber].Print();
             }
         }
     }
 }