コード例 #1
0
        public SnakeGame(IReadOnlyList <ISnakeController> controllers)
        {
            Controllers     = controllers;
            graphics        = new GraphicsDeviceManager(this);
            scorePosition   = new Vector2(ScreenWidth / 2f, 50);
            rand            = new Random();
            gridDescription = new GridDescription(GridSize, RowCount, ColumnCount);

            Content.RootDirectory = "Content";
            Window.Title          = "Snake";
        }
コード例 #2
0
        internal GameInstance(GridDescription gridDescription, Snake snake, ISnakeController controller, RandomFoodGenerator randomFoodGenerator)
        {
            this.gridDescription     = gridDescription;
            this.snake               = snake;
            this.controller          = controller;
            this.randomFoodGenerator = randomFoodGenerator;

            foodPosition         = GenerateFoodPosition();
            elapsedTimeSinceMove = 0;
            speed        = 10;
            IsSnakeAlive = true;
            Score        = 0;
        }
コード例 #3
0
 public RandomFoodGenerator(GridDescription gridDescription, Random randomGenerator)
 {
     this.gridDescription = gridDescription;
     this.randomGenerator = randomGenerator;
     squaresCount         = gridDescription.RowCount * gridDescription.ColumnCount;
 }