Ejemplo n.º 1
0
 public override void Init(int rows, int columns)
 {
     base.Init(rows, columns);
     _GameGrid = new Color[rows, columns];
     GameActions.Where(action => action.Button == GameButton.Up).FirstOrDefault().Duration = 250;
     _Tetromino = new Tetromino(columns);
 }
Ejemplo n.º 2
0
        public override void Update(List<GameButton> buttons, byte[,] touchInput, List<GameButton> buttonInputs)
        {
            //if (buttons.Where(action => action == GameButton.A).Any())
            //{
            //    _Tetromino = new Tetromino(GameColumns);
            //}

            if (buttons.Where(action => action == GameButton.Up).Any())
            {
                if (_Tetromino != null)
                {
                    _Tetromino.Rotate(_GameGrid);
                }
            }

            if (buttons.Where(action => action == GameButton.Left).Any())
            {
                if (_Tetromino != null)
                {
                    _Tetromino.Move(-1, 0, _GameGrid);
                }
            }

            if (buttons.Where(action => action == GameButton.Right).Any())
            {
                if (_Tetromino != null)
                {
                    _Tetromino.Move(1, 0, _GameGrid);
                }
            }

            int moveDown = 0;

            if (buttons.Where(action => action == GameButton.Down).Any())
            {
                moveDown += 2;
            }

            if (_lastMoveDown + (ulong)_MoveSpeed*1000 < Looptime)
            {
                moveDown +=1;
                _lastMoveDown = Looptime;
            }

            if (moveDown > 0)
            {
                for (int i = 0; i < moveDown; i++)
                {
                    if (_Tetromino != null)
                    {
                        bool isDown = _Tetromino.Move(0, 1, _GameGrid);
                        if (isDown)
                        {
                            if (_Tetromino != null)
                            {
                                foreach (Point point in _Tetromino.Figure)
                                {
                                    _GameGrid[(int)(point.Y + _Tetromino.CurrentPosition.Y), (int)(point.X + _Tetromino.CurrentPosition.X)] = _Tetromino.Color;
                                }
                            }

                            RemoveFullRows();

                            _Tetromino = new Tetromino(GameColumns);
                            break;
                        }
                    }
                }
            }
        }