//public BackgroundSprite(Texture2D _texture, Vector2 _position, float _speed, float _speedConstant, float _screenWidth, float _screenHeight, Vector2 _direction)
        //{
        //    speed = _speed;
        //    speedConstant = _speedConstant;
        //    texture = _texture;
        //    position = _position;
        //    screenHeight = _screenHeight;
        //    screenWidth = _screenWidth;
        //    positionImage5 = position;
        //}
        /// <summary>
        /// Moves the bg in a positive horizontal position(left).
        /// </summary>
        /// <param name="_timeDelta">gameTime total elapsed seconds.</param>
        public void Update(GameTime gameTime, Controls cont, Vector2 _centerPosition)
        {
            float timeDelta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (cont.moveRight())
            {
                movingLeft = false;
                movingRight = true;
                venesPosition -= new Vector2(0.5f, 0);
            }
            else if (cont.moveLeft())
            {
                movingLeft = true;
                movingRight = false;
                venesPosition += new Vector2(0.5f, 0);
            }
            else if (cont.moveUp())
            {
                movingUp = true;
                movingDown = false;
                venesPosition += new Vector2(0, 0.5f);
            }
            else if (cont.moveDown())
            {
                movingUp = false;
                movingDown = true;
                venesPosition -= new Vector2(0, 0.5f);
            }

            //else
            //{
            //    movingUp = false;
            //    movingDown = false;
            //}

            /*
            if (movingUp)
                moveUp(timeDelta);
            if (movingDown)
                moveDown(timeDelta);
            if (movingLeft)
                moveLeft(timeDelta);
            if (movingRight)
                moveRight(timeDelta);

             */

            #region BG Repeater Right Movement

            if (positionImage1.X < (-texture.Width / 2) + _centerPosition.X - (texture.Width))
            {
                positionImage1.X = positionImage1.X + (texture.Width * 2);
                positionImage4.X = positionImage4.X + (texture.Width * 2);
                positionImage7.X = positionImage7.X + (texture.Width * 2);
            }

            if (positionImage2.X < (-texture.Width / 2) + _centerPosition.X - (texture.Width))
            {
                positionImage2.X = positionImage2.X + (texture.Width * 2);
                positionImage5.X = positionImage5.X + (texture.Width * 2);
                positionImage8.X = positionImage8.X + (texture.Width * 2);
            }

            if (positionImage3.X < (-texture.Width / 2) + _centerPosition.X - (texture.Width))
            {
                positionImage3.X = positionImage3.X - (texture.Width * 2);
                positionImage6.X = positionImage6.X - (texture.Width * 2);
                positionImage9.X = positionImage9.X - (texture.Width * 2);
            }

            #region w/o camera old code
            /////////////////////////////////////////////////////////
            //////////////////////  second row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage4.X < -1 * (texture.Width))
            //{
            //    positionImage4.X = positionImage4.X + (texture.Width * 2);
            //}

            //if (positionImage5.X < -1 * (texture.Width))
            //{
            //    positionImage5.X = positionImage5.X + (texture.Width * 2);
            //}
            //if (positionImage6.X < -1 * (texture.Width))
            //{
            //    positionImage6.X = positionImage6.X - (texture.Width * 2);
            //}

            /////////////////////////////////////////////////////////
            //////////////////////  third row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage7.X < -1 * (texture.Width))
            //{
            //    positionImage7.X = positionImage7.X + (texture.Width * 2);
            //}

            //if (positionImage8.X < -1 * (texture.Width))
            //{
            //    positionImage8.X = positionImage8.X + (texture.Width * 2);
            //}
            //if (positionImage9.X < -1 * (texture.Width))
            //{
            //    positionImage9.X = positionImage9.X - (texture.Width * 2);
            //}
            #endregion
            #endregion

            #region BG Repeater Left Movement

            if (positionImage1.X > _centerPosition.X - (texture.Width / 2) + (texture.Width))
            {
                positionImage1.X = positionImage1.X - (texture.Width * 2);
                positionImage4.X = positionImage4.X - (texture.Width * 2);
                positionImage7.X = positionImage7.X - (texture.Width * 2);
            }

            if (positionImage2.X > _centerPosition.X - (texture.Width / 2) + (texture.Width))
            {
                positionImage2.X = positionImage2.X - (texture.Width * 2);
                positionImage5.X = positionImage5.X - (texture.Width * 2);
                positionImage8.X = positionImage8.X - (texture.Width * 2);
            }

            if (positionImage3.X > _centerPosition.X - (texture.Width / 2) + (texture.Width))
            {
                positionImage3.X = positionImage3.X - (texture.Width * 2);
                positionImage6.X = positionImage6.X - (texture.Width * 2);
                positionImage9.X = positionImage9.X - (texture.Width * 2);
            }
            #region w/o camera old code
            /////////////////////////////////////////////////////////
            //////////////////////  second row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage4.X > (texture.Width))
            //{
            //    positionImage4.X = positionImage4.X - (texture.Width * 2);
            //}

            //if (positionImage5.X > (texture.Width))
            //{
            //    positionImage5.X = positionImage5.X - (texture.Width * 2);
            //}

            //if (positionImage6.X > (texture.Width))
            //{
            //    positionImage6.X = positionImage6.X - (texture.Width * 2);
            //}

            /////////////////////////////////////////////////////////
            //////////////////////  third row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage7.X > (texture.Width))
            //{
            //    positionImage7.X = positionImage7.X - (texture.Width * 2);
            //}

            //if (positionImage8.X > (texture.Width))
            //{
            //    positionImage8.X = positionImage8.X - (texture.Width * 2);
            //}

            //if (positionImage9.X > (texture.Width))
            //{
            //    positionImage9.X = positionImage9.X - (texture.Width * 2);
            //}

            #endregion
            #endregion

            #region BG Repeater Up Movement

            if (positionImage1.Y < (_centerPosition.Y - (texture.Width / 2)) - (texture.Height))
            {
                positionImage1.Y = positionImage1.Y + (texture.Height * 2);
                positionImage2.Y = positionImage2.Y + (texture.Height * 2);
                positionImage3.Y = positionImage3.Y + (texture.Height * 2);
            }

            if (positionImage4.Y < (_centerPosition.Y - (texture.Width / 2)) - (texture.Height))
            {
                positionImage4.Y = positionImage4.Y + (texture.Height * 2);
                positionImage5.Y = positionImage5.Y + (texture.Height * 2);
                positionImage6.Y = positionImage6.Y + (texture.Height * 2);
            }
            if (positionImage7.Y < (_centerPosition.Y - (texture.Width / 2)) - (texture.Height * 2))
            {
                positionImage7.Y = positionImage7.Y + (texture.Height * 2);
                positionImage8.Y = positionImage8.Y + (texture.Height * 2);
                positionImage9.Y = positionImage9.Y + (texture.Height * 2);
            }

            #region old code w/o camera

            /////////////////////////////////////////////////////////
            //////////////////////  second row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage4.Y < -1 * (texture.Height))
            //{
            //    positionImage4.Y = positionImage4.Y + (texture.Height * 2);
            //}

            //if (positionImage5.Y < -1 * (texture.Height))
            //{
            //    positionImage5.Y = positionImage5.Y + (texture.Height * 2);
            //}
            //if (positionImage6.Y < -1 * (texture.Height))
            //{
            //    positionImage6.Y = positionImage6.Y - (texture.Height * 2);
            //}

            /////////////////////////////////////////////////////////
            //////////////////////  third row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage7.Y < -1 * (texture.Height))
            //{
            //    positionImage7.Y = positionImage7.Y + (texture.Height * 2);
            //}

            //if (positionImage8.Y < -1 * (texture.Height))
            //{
            //    positionImage8.Y = positionImage8.Y + (texture.Height * 2);
            //}
            //if (positionImage9.Y < -1 * (texture.Height))
            //{
            //    positionImage9.Y = positionImage9.Y - (texture.Height * 2);
            //}

            #endregion
            #endregion

            #region BG Repeater Down Movement

            if (positionImage1.Y > (_centerPosition.Y - (texture.Width / 2)) + (texture.Height))
            {
                positionImage1.Y = positionImage1.Y - (texture.Height * 2);
                positionImage2.Y = positionImage2.Y - (texture.Height * 2);
                positionImage3.Y = positionImage3.Y - (texture.Height * 2);
            }

            if (positionImage4.Y > (_centerPosition.Y - (texture.Width / 2)) + (texture.Height))
            {
                positionImage4.Y = positionImage4.Y - (texture.Height * 2);
                positionImage5.Y = positionImage5.Y - (texture.Height * 2);
                positionImage6.Y = positionImage6.Y - (texture.Height * 2);
            }
            if (positionImage7.Y > (_centerPosition.Y - (texture.Width / 2)) + (texture.Height * 2))
            {
                positionImage7.Y = positionImage7.Y - (texture.Height * 2);
                positionImage8.Y = positionImage8.Y - (texture.Height * 2);
                positionImage9.Y = positionImage9.Y - (texture.Height * 2);
            }

            #region old code w/o camera
            /////////////////////////////////////////////////////////
            //////////////////////  second row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage4.Y > texture.Height)
            //{
            //    positionImage4.Y = positionImage4.Y - (texture.Height * 2);
            //}

            //if (positionImage5.Y > texture.Height)
            //{
            //    positionImage5.Y = positionImage5.Y - (texture.Height * 2);
            //}
            //if (positionImage6.Y > texture.Height)
            //{
            //    positionImage6.Y = positionImage6.Y + (texture.Height * 2);
            //}

            /////////////////////////////////////////////////////////
            //////////////////////  third row  //////////////////////
            /////////////////////////////////////////////////////////

            //if (positionImage7.Y > texture.Height)
            //{
            //    positionImage7.Y = positionImage7.Y - (texture.Height * 2);
            //}

            //if (positionImage8.Y > texture.Height)
            //{
            //    positionImage8.Y = positionImage8.Y - (texture.Height * 2);
            //}
            //if (positionImage9.Y > texture.Height)
            //{
            //    positionImage9.Y = positionImage9.Y + (texture.Height * 2);
            //}

            #endregion

            #endregion
        }
        public void Update(Controls key)
        {
            if(!dataLoaded)
                LoadFromDevice();

            level0Percent = Convert.ToInt32(loadData.saveLevel0);
            level1Percent = Convert.ToInt32(loadData.saveLevel1);
            level2Percent = Convert.ToInt32(loadData.saveLevel2);
            level3Percent = Convert.ToInt32(loadData.saveLevel3);
            level4Percent = Convert.ToInt32(loadData.saveLevel4);
            level5Percent = Convert.ToInt32(loadData.saveLevel5);
            level6Percent = Convert.ToInt32(loadData.saveLevel6);
            level7Percent = Convert.ToInt32(loadData.saveLevel7);
            playedLevel0 = Convert.ToInt32(loadData.level0Played);
            averageLevel0 = Convert.ToUInt32(loadData.level0Average);
            playedLevel1 = Convert.ToInt32(loadData.level1Played);
            averageLevel1 = Convert.ToUInt32(loadData.level1Average);
            playedLevel2 = Convert.ToInt32(loadData.level2Played);
            averageLevel2 = Convert.ToUInt32(loadData.level2Average);
            playedLevel3 = Convert.ToInt32(loadData.level3Played);
            averageLevel3 = Convert.ToUInt32(loadData.level3Average);
            playedLevel4 = Convert.ToInt32(loadData.level4Played);
            averageLevel4 = Convert.ToUInt32(loadData.level4Average);
            playedLevel5 = Convert.ToInt32(loadData.level5Played);
            averageLevel5 = Convert.ToUInt32(loadData.level5Average);
            playedLevel6 = Convert.ToInt32(loadData.level6Played);
            averageLevel6 = Convert.ToUInt32(loadData.level6Average);
            playedLevel7 = Convert.ToInt32(loadData.level7Played);
            averageLevel7 = Convert.ToUInt32(loadData.level7Average);

            level0Fastest = Convert.ToInt32(loadData.level0Fastest);
            level1Fastest = Convert.ToInt32(loadData.level1Fastest);
            level2Fastest = Convert.ToInt32(loadData.level2Fastest);
            level3Fastest = Convert.ToInt32(loadData.level3Fastest);
            level4Fastest = Convert.ToInt32(loadData.level4Fastest);
            level5Fastest = Convert.ToInt32(loadData.level5Fastest);
            level6Fastest = Convert.ToInt32(loadData.level6Fastest);
            level7Fastest = Convert.ToInt32(loadData.level7Fastest);

            if (key.moveLeft() && timer == 0)
            {
                if (selected > 0)
                    selected--;

                timer = 30;
            }

            if (key.moveRight() && timer == 0)
            {
                if (selected < 7)
                    selected++;

                timer = 30;
            }

            level0Size = minScale;
            level1Size = minScale;
            level2Size = minScale;
            level3Size = minScale;
            level4Size = minScale;
            level5Size = minScale;
            level6Size = minScale;
            level7Size = minScale;

            level0Pos = new Vector2(2000, 0);
            level1Pos = new Vector2(2000, 0);
            level2Pos = new Vector2(2000, 0);
            level3Pos = new Vector2(2000, 0);
            level4Pos = new Vector2(2000, 0);
            level5Pos = new Vector2(2000, 0);
            level6Pos = new Vector2(2000, 0);
            level7Pos = new Vector2(2000, 0);

            switch (selected)
            {
                case 0:
                    {
                        level0Size = maxScale;
                        level0Pos = new Vector2(0, 0);
                        level1Pos = new Vector2(410, 76);
                    }
                    break;
                case 1:
                    {
                        level1Size = maxScale;
                        level0Pos = new Vector2(-210, 76);
                        level1Pos = new Vector2(0, 0);
                        level2Pos = new Vector2(410, 76);
                    }
                    break;
                case 2:
                    {
                        level2Size = maxScale;
                        level1Pos = new Vector2(-210, 76);
                        level2Pos = new Vector2(0, 0);
                        level3Pos = new Vector2(410, 76);
                    }
                    break;
                case 3:
                    {
                        level3Size = maxScale;
                        level2Pos = new Vector2(-210, 76);
                        level3Pos = new Vector2(0, 0);
                        level4Pos = new Vector2(410, 76);
                    }
                    break;
                case 4:
                    {
                        level4Size = maxScale;
                        level3Pos = new Vector2(-210, 76);
                        level4Pos = new Vector2(0, 0);
                        level5Pos = new Vector2(410, 76);
                    }
                    break;
                case 5:
                    {
                        level5Size = maxScale;
                        level4Pos = new Vector2(-210, 76);
                        level5Pos = new Vector2(0, 0);
                        level6Pos = new Vector2(410, 76);
                    }
                    break;
                case 6:
                    {
                        level6Size = maxScale;
                        level5Pos = new Vector2(-210, 76);
                        level6Pos = new Vector2(0, 0);
                        level7Pos = new Vector2(410, 76);
                    }
                    break;
                case 7:
                    {
                        level7Size = maxScale;
                        level6Pos = new Vector2(-210, 76);
                        level7Pos = new Vector2(0, 0);

                    }
                    break;

                default: break;
            }

            if (key.accept() && timer == 0)
            {
                if (selected == 0)
                    menuChoosen = true;
                if (selected == 1 && level0Percent > 0)
                    menuChoosen = true;
                if (selected == 2 && level1Percent > 0)
                    menuChoosen = true;
                if (selected == 3 && level2Percent > 0)
                    menuChoosen = true;
                if (selected == 4 && level3Percent > 0)
                    menuChoosen = true;
                if (selected == 5 && level4Percent > 0)
                    menuChoosen = true;
                if (selected == 6 && level5Percent > 0)
                    menuChoosen = true;
                if (selected == 7 && level6Percent > 0)
                    menuChoosen = true;

                timer = 30;
            }

            if (timer > 0)
                timer--;
        }