Пример #1
0
        private void SpawnAppleRandomly()
        {
            Random rnd  = new Random();
            int    maxX = GenericGameObjectsFactory.getGraphics().PreferredBackBufferWidth;
            int    maxY = GenericGameObjectsFactory.getGraphics().PreferredBackBufferHeight;

            Vector2 randPos = new Vector2(rnd.Next(maxX), rnd.Next(maxY));

            apple = new Apple(GenericGameObjectsFactory.getContentManager().Load <Texture2D>("apple"), randPos);
            apple.Attach(this);
            apple.Attach(snake);

            ComponentManager.attachComponent(apple);
        }
Пример #2
0
        public Scene()
        {
            snake = new Snake(GenericGameObjectsFactory.getContentManager().Load <Texture2D>("segment"), Direction.SOUTH, new Vector2(100, 100), 10);
            snake.Attach(this);
            snake.Attach(pointsLabel);
            //snake.Attach(coordinatesLabel);
            label.Text = "";

            inputController = new InputController(snake);

            SpawnAppleRandomly();

            ComponentManager.attachComponent(inputController);
            ComponentManager.attachComponent(snake);
            ComponentManager.attachComponent(pointsLabel);
            ComponentManager.attachComponent(label);
            //ComponentManager.attachComponent(coordinatesLabel);
        }