private bool Validate_Movement(Vector3 future_position, Tree[] trees, Zombie[] zombies)
        {
            //Don't allow player to go off map
            if ((Math.Abs(future_position.X) > max_range) ||
                (Math.Abs(future_position.Z) > max_range))
                return false;

            //Don't allow player to go through trees
            if (Check_For_Tree_Collision(future_position, trees))
                return false;
            if (Check_For_Zombie_Collision(future_position, zombies))
            {
                if (health_timer > 15)
                {
                    health -= 10;
                    health_timer = 0;
                }
                return true;
            }
            return true;
        }
        public void Update(GamePadState gamepad_state, KeyboardState keyboard_state, Tree[] trees, Zombie[] zombies, double elapsedTime)
        {
            Vector3 future_position = position;
            health_timer++;
            float turn_amount = 0;

            if (keyboard_state.IsKeyDown(Keys.A))
                turn_amount = 1;
            else if (keyboard_state.IsKeyDown(Keys.D))
                turn_amount = -1;
            else if (gamepad_state.ThumbSticks.Left.X != 0)
                turn_amount = gamepad_state.ThumbSticks.Left.X;

            //calculate turn amount and direction
            forward_direction += turn_amount * GlobalState.PLAYER_TURN_SPEED * (float) elapsedTime;
            Matrix orientation_matrix = Matrix.CreateRotationY(forward_direction);

            Vector3 movement = Vector3.Zero;
            if (keyboard_state.IsKeyDown(Keys.W))
                movement.Z = 1;
            else if (keyboard_state.IsKeyDown(Keys.S))
                movement.Z = -1;
            else if (gamepad_state.ThumbSticks.Left.Y != 0)
                movement.Z = gamepad_state.ThumbSticks.Left.Y;

            //if (movement.Z > 0)
            //{
                Vector3 speed = Vector3.Transform(movement, orientation_matrix);
                speed *= GlobalState.PLAYER_VELOCITY;
                future_position = position + speed;

                if (Validate_Movement(future_position, trees, zombies))
                {
                    position = future_position;
                }
                else position -= (3*speed);
        }
 private bool Check_For_Tree_Collision(Vector3 future_position, Tree[] trees)
 {
     for (int cur_tree = 0; cur_tree < trees.Length; cur_tree++)
     {
         //calc distance
         if (Calc_Distance(trees[cur_tree].position, future_position) < GlobalState.COLLISION_DISTANCE)
             return true;
     }
     return false;
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            device = graphics.GraphicsDevice;
            zombie = Content.Load<Model>("Models/Zombie");
            shotgun.model = Content.Load<Model>("Models/Shotgun");
            handgun.model = Content.Load<Model>("Models/box");

            //Guns
            guns.LoadContent(Content, "Models/Rifle2", "Models/box", "Textures/muzzleflash");
            //guns.LoadContent(Content, "Textures/muzzleflash");
            //tree = Content.Load<Model>("Models/firtree1");
            grassTexture = Content.Load<Texture2D>("Textures/grass");
            blackTexture = Content.Load<Texture2D>("Textures/grass");
            brickTexture = Content.Load<Texture2D>("Textures/brick_wall_tex");
            health_bar = Content.Load<Texture2D>("Textures/health_bar");
            //Game Screens
            startGame = Content.Load<Texture2D>("Models/StartGame");
            gameOver = Content.Load<Texture2D>("Models/GameOver");
            winState = Content.Load<Texture2D>("Models/winState");
            NEWLEVEL = Content.Load<Texture2D>("Models/NEWLEVEL");
            pause_screen = Content.Load<Texture2D>("Models/Pause_Screen");
            //Skybox
            skyboxModel = Content.Load<Model>("Textures/skybox2");
            skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
            //new code
            ground.model = Content.Load<Model>("Models/box");
            brick_wall.model = Content.Load<Model>("Models/box");
            statsFont = Content.Load<SpriteFont>("Fonts/StatsFont");
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Initialize zombies
            zombies = new Zombie[killTotal];
            for (int index = 0; index < zombies.Length; index++)
            {
                zombies[index] = new Zombie();
                zombies[index].LoadContent(Content, "Models/Zombie");
            }

            //initialize trees
            trees = new Tree[GlobalState.NUM_TREES];

            for (int index = 0; index < trees.Length; index++)
            {
                trees[index] = new Tree();
                trees[index].LoadContent(Content, "Models/firtree1");

            }

            //initialize player
            player = new Player();
            player.LoadContent(Content, "Models/box");

            //Function for placing trees and zombies
            PlaceTreesAndZombies();
            // TODO: use this.Content to load your game content here

            SoundEffect soundEffect;

            soundEffect = Content.Load<SoundEffect>("audio/backgroundmusic");
            background_music = soundEffect.CreateInstance();
            soundEffect = Content.Load<SoundEffect>("audio/gunsound");
            gun_sound = soundEffect.CreateInstance();
            gun_sound.Volume = GlobalState.GUN_SOUND_VOLUME;
            background_music.IsLooped = true;
            background_music.Volume = GlobalState.BACKGROUND_MUSIC_VOLUME;
        }