Exemplo n.º 1
0
        private void DrawBackgroundsVertically(SpriteBatch spriteBatch, Backgrounds background)
        {
            //if (background.position2.Y + background.sprite.Height < 0)
            //{
            //    background.position2.Y = background.position.Y - background.sprite.Height;
            //}

            //if (background.position.X + background.sprite.Height < 0)
            //{
            //    background.position.X = background.position2.Y - background.sprite.Height;
            //}

            if (background.position2.Y > 720)
            {
                background.position2.Y = background.position.Y - background.sprite.Height;
            }

            if (background.position.Y > 720)
            {
                background.position.Y = background.position2.Y - background.sprite.Height;
            }


            //the following 2 lines could be optimized to only draw if it's on screen. oh well.
            spriteBatch.Draw(background.sprite, background.position, Color.White);
            spriteBatch.Draw(background.sprite, background.position2, Color.White);
        }
Exemplo n.º 2
0
        private void DrawBackgroundsHorizontally(SpriteBatch spriteBatch, Backgrounds background)
        {
            if (background.position2.X + background.sprite.Width < 0)
            {
                background.position2.X = background.position.X + background.sprite.Width;
            }

            if (background.position.X + background.sprite.Width < 0)
            {
                background.position.X = background.position2.X + background.sprite.Width;
            }
            //the following 2 lines could be optimized to only draw if it's on screen. oh well.
            spriteBatch.Draw(background.sprite, background.position, Color.White);
            spriteBatch.Draw(background.sprite, background.position2, Color.White);
        }