示例#1
0
 public void Game()
 {
     board = new Board(25, 20);
     GenerateTetrominos();
     Tetromino.Spawn(currTetromino, board);
     board.DrawBoard();
     deltaTime.Start();
     while (isPlaying)
     {
         input();
         Update();
     }
 }
示例#2
0
 public void Update()
 {
     if (Collisions.dropCollisionCheck(currTetromino, board))
     {
         deltaTime.Reset();
         checkRows();
         GenerateTetrominos();
         Tetromino.Spawn(currTetromino, board);
         deltaTime.Start();
     }
     if (deltaTime.ElapsedMilliseconds > dropRate)
     {
         Drop();
         deltaTime.Restart();
         board.DrawBoard();
     }
 }
示例#3
0
        public bool Update()
        {
            if (!GameOver)
            {
                if (current == null)
                {
                    current = new Tetromino(this);
                    List <Tetromino.Shapes> shapeNames = Tetromino.Structures.Keys.ToList();
                    Tetromino.Shapes        newShape   = shapeNames[r.Next(shapeNames.Count)];
                    current.Spawn(newShape, 3, 0, r.Next(4));
                }
                else
                {
                    bool done = current.MoveDown();
                    if (done)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            for (int j = 0; j < Width; j++)
                            {
                                if (Grid[j, i] != Color.Transparent)
                                {
                                    GameOver = true;
                                    break;
                                }
                            }
                            if (GameOver)
                            {
                                break;
                            }
                        }

                        ClearFullLines();

                        current = new Tetromino(this);
                        List <Tetromino.Shapes> shapeNames = Tetromino.Structures.Keys.ToList();
                        Tetromino.Shapes        newShape   = shapeNames[r.Next(shapeNames.Count)];
                        current.Spawn(newShape, 3, 0, r.Next(4));
                    }
                }
            }
            return(GameOver);
        }
示例#4
0
        public bool Update()
        {
            if (!GameOver)
            {
                if (current == null)
                {
                    current = new Tetromino(this);
                    List<Tetromino.Shapes> shapeNames = Tetromino.Structures.Keys.ToList();
                    Tetromino.Shapes newShape = shapeNames[r.Next(shapeNames.Count)];
                    current.Spawn(newShape, 3, 0, r.Next(4));
                }
                else
                {
                    bool done = current.MoveDown();
                    if (done)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            for (int j = 0; j < Width; j++)
                            {
                                if (Grid[j, i] != Color.Transparent)
                                {
                                    GameOver = true;
                                    break;
                                }
                            }
                            if (GameOver)
                                break;
                        }

                        ClearFullLines();

                        current = new Tetromino(this);
                        List<Tetromino.Shapes> shapeNames = Tetromino.Structures.Keys.ToList();
                        Tetromino.Shapes newShape = shapeNames[r.Next(shapeNames.Count)];
                        current.Spawn(newShape, 3, 0, r.Next(4));
                    }
                }
            }
            return GameOver;
        }