Esempio n. 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            mCameraHandler.Update(gameTime.ElapsedGameTime.Milliseconds);

            // Does crash in -Z direction (when leaving terrain backwards)
            mCamera.mLocation.Y = mTerrain.GetHeight(mCamera.mLocation) + 2.0f;

            // TODO: Add your update logic here
            mCamera.UpdateView();

            mFrustumCulling.CullActorsOutsideFrustum(mScene, mCamera);

            var nearestActor = RayCasting.CastRayFromMousePosition(mViewport, mCamera, mScene);

            var mouseState = Mouse.GetState();

            if (nearestActor != null && mouseState.RightButton == ButtonState.Pressed)
            {
                mScene.Remove(nearestActor);
            }

            base.Update(gameTime);
        }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            mCameraHandler.Update(gameTime.ElapsedGameTime.Milliseconds);

            // TODO: Add your update logic here
            mCamera.UpdateView();

            base.Update(gameTime);
        }