//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 }