Exemplo n.º 1
0
        public MainWindowViewModel()
        {
            var gameBoard = new GameBoard(Parameters.RowCount, Parameters.ColumnCount);

            directionBuffer = new DirectionBuffer(Parameters.InitialDirection);
            SnakeState      = new SnakeState(Parameters.SnakeInitialLength, Parameters.ScoreFactor);
            gameLogic       = new GameLogic(gameBoard, directionBuffer, SnakeState);

            FlatBoard   = new ObservableCollection <Cell>(gameBoard.FlatBoard());
            RowCount    = gameBoard.RowCount;
            ColumnCount = gameBoard.ColumnCount;
        }
Exemplo n.º 2
0
        public GameLogic(GameBoard gameBoard, DirectionBuffer directionBuffer, SnakeState snakeState)
        {
            this.directionBuffer = directionBuffer;
            this.snakeState      = snakeState;

            snake = new Snake(gameBoard, snakeState, Parameters.SnakeInitialRow, Parameters.SnakeInitialColumn, Parameters.SnakeInitialLength);
            food  = new Food(gameBoard, snake);

            speedMsPerMove = Parameters.SpeedMsPerMove;

            snakeState.IsDead = true;

            Task.Run(() => KeepMoving());
        }