Ejemplo n.º 1
0
 private void StartGame()
 {
     this.score = 0;
     this.modifier = 100;
     timerMain.Interval = this.interval;
     this.totLines = 0;
     level = 1;
     grid = new TetrisGrid(gridWidth, gridHeight, scaleX, scaleY);
     curBlock = grid.CreateNewBlock(RandomBlock(), gridWidth / 2 - 1, 0);
     nextBlock = new TetrisBlock(RandomBlock(), 12, 12, scaleX, scaleY);
     timerMain.Start();
 }
Ejemplo n.º 2
0
 public TetrisBlock CreateNewBlock(string type, int x, int y)
 {
     curBlock = new TetrisBlock(type, x, y, scaleX, scaleY);
     return curBlock;
 }
Ejemplo n.º 3
0
        private void MoveBlockDown()
        {
            curBlock.MoveDown(dy);
            if (grid.IsCollision())
            {
                if (curBlock.y <= 2)
                {
                    curBlock.MoveUp(dy);
                    this.Invalidate();
                    isGameOver = true;
                    return;
                }
                curBlock.MoveUp(dy);
                grid.AddBlockToGrid();
                int lines = grid.ClearLines();
                totLines += lines;
                score += lines * modifier;

                // give a 2x modifier for 3 cleared lines; another 2x for 4 cleared lines
                if (lines >= 3)
                {
                    lblBonus.Visible = true;
                    modifier *= 2;
                }
                if (lines == 4)
                    modifier *= 2;

                curBlock = grid.CreateNewBlock(nextBlock.type, gridWidth / 2 - 1, 0);
                nextBlock = new TetrisBlock(RandomBlock(), 12, 12, scaleX, scaleY);
            }
        }
Ejemplo n.º 4
0
 public TetrisBlock CreateNewBlock(string type, int x, int y)
 {
     curBlock = new TetrisBlock(type, x, y, scaleX, scaleY);
     return(curBlock);
 }