Beispiel #1
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();
            mouseState = mouseManager.GetState();

            // Handle base.Update
            base.Update(gameTime);

            //Update game objects
            lightsource.Update(gameTime);
            model.Update(gameTime, lightsource.getLightDirection());
            water.Update(gameTime, lightsource.getLightDirection());
            camera.Update(gameTime);

            //Enable/disable cursor control of the camera
            if (keyboardState.IsKeyPressed(Keys.Space)){
                if(enableCursor == true){
                    enableCursor = false;
                }
                else{
                    enableCursor = true;
                }
            }

            //Exit the game
            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
                this.Dispose();
            }
        }
Beispiel #2
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Calculates the world and the view based on the model size
            view = Matrix.LookAtRH(new Vector3(0.0f, 0.0f, 7.0f), new Vector3(0, 0.0f, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovRH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f);

            // Update basic effect for rendering the Primitive
            _textureEffect.View = view;
            _textureEffect.Projection = projection;
            _textureEffect.CameraPosition = new Vector3(0.0f, 0.0f, 70.0f);

            _exampleEffect.View = view;
            _exampleEffect.Projection = projection;
            _exampleEffect.CameraPosition = new Vector3(0.0f, 0.0f, 70.0f);

            // Get the current state of the keyboard
            keyboardState = keyboard.GetState();

            if (keyboardState.IsKeyPressed(Keys.D1))
                _wireframe ^= true;
        }
Beispiel #3
0
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // update keyboard state
            keyboardState = keyboardManager.GetState();

            // if Esc is pressed - quit program
            if (keyboardState.IsKeyPressed(Keys.Escape))
            {
                Exit();
                return;
            }

            // numer keys (NOT numpad ones) have name like D0, D1, etc...
            // associate available modes each with its key
            for (int i = 0; i < availableModes.Count; i++)
            {
                var key = (Keys)Enum.Parse(typeof(Keys), "D" + i);
                if (keyboardState.IsKeyPressed(key))
                {
                    ApplyMode(availableModes[i]);
                    return;
                }
            }
        }