Exemplo n.º 1
0
        /// <summary>
        /// Initalize the game
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            debug = new DebugDraw(GraphicsDevice);

            // Load ship and add to collision manager
            ship = new Ship(GraphicsDevice);

            // Load enemy ships and add to collision manager
            const int numEnemies = 5;

            enemies = new List <EnemyShip>();
            Random rand = new Random();

            for (int i = 0; i < numEnemies; i++)
            {
                EnemyShip enemy = new EnemyShip(GraphicsDevice);

                // Generate two floats between -1.0f and 1.0f
                float randX = (float)(rand.NextDouble() - rand.NextDouble());
                float randZ = (float)(rand.NextDouble() - rand.NextDouble());

                enemy.Position = new Vector3(randX * 50000.0f, 350.0f, randZ * 50000.0f);
                enemies.Add(enemy);
            }

            // Initialise the collidable objects
            InitializeCollidableObjects();

            // Set the camera aspect ratio
            // This must be done after the class to base.Initalize() which will
            // initialize the graphics device.
            camera.AspectRatio = (float)graphics.GraphicsDevice.Viewport.Width /
                                 graphics.GraphicsDevice.Viewport.Height;


            // Perform an inital reset on the camera so that it starts at the resting
            // position. If we don't do this, the camera will start at the origin and
            // race across the world to get behind the chased object.
            // This is performed here because the aspect ratio is needed by Reset.
            UpdateCameraChaseTarget();
            camera.Reset();

            InitializeBindings();
        }
        /// <summary>
        /// Initalize the game
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();


            // Set the camera aspect ratio
            // This must be done after the class to base.Initalize() which will
            // initialize the graphics device.
            camera.AspectRatio = (float)graphics.GraphicsDevice.Viewport.Width /
                                 graphics.GraphicsDevice.Viewport.Height;


            // Perform an inital reset on the camera so that it starts at the resting
            // position. If we don't do this, the camera will start at the origin and
            // race across the world to get behind the chased object.
            // This is performed here because the aspect ratio is needed by Reset.
            UpdateCameraChaseTarget();
            camera.Reset();
        }