Exemplo n.º 1
0
 public RocketSprite(ImageSprite sprite,
                     SpaceRocketsInSpaceGame game,
                     double xSpeed, double ySpeed) :
     base(sprite, xSpeed, ySpeed)
 {
     gameValue = game;
 }
Exemplo n.º 2
0
        /// <summary>Updates the position and orientation of all sprites on each timer tick.</summary>
        /// <param name="sender">The timer.</param>
        /// <param name="e">Event args.</param>
        private void UpdateSpritesOnTimerTick(object sender, EventArgs e)
        {
            if (_timer != null)
            {
                if (_sprites != null)
                {
                    // Update each sprite
                    for (int i = _sprites.Count - 1; i >= 0; --i)
                    {
                        // Update the sprite
                        ImageSprite s = _sprites[i];
                        s.Update();

                        // If it's left the visible range, remove it from the list so we don't
                        // need to deal with it any more
                        Rectangle bounds = ClientRectangle;
                        if (s.Location.X > bounds.Right + s.Image.Width || s.Location.X < -s.Image.Width ||
                            s.Location.Y > bounds.Bottom + s.Image.Width || s.Location.Y < -s.Image.Width)
                        {
                            _sprites.RemoveAt(i);
                            s.Dispose();
                        }
                    }

                    // If there are no sprites left, stop the timer; we're done.
                    if (_sprites.Count == 0)
                    {
                        _timer.Stop();                                          // stop but don't delete, as _timer is used as a marker
                    }
                    // Refresh the window
                    Invalidate();
                }
            }
        }
Exemplo n.º 3
0
        internal ImageSprite GetSprite(ImageSourceId id)
        {
            List <ImageSprite> spriteList;

            sprites.TryGetValue(id, out spriteList);

            if (spriteList == null)
            {
                spriteList = new List <ImageSprite>();
                sprites.Add(id, spriteList);
            }

            int frame = GraphicsDevice.CurrentSpriteFrameNumber;

            foreach (ImageSprite sprite in spriteList)
            {
                if (sprite.usedOnFrame != frame)
                {
                    return(sprite);
                }
            }

            // No suitable sprite found, add one:
            ImageSprite createSprite = new ImageSprite(this, id);

            GraphicsDevice.AddSprite(createSprite);
            spriteList.Add(createSprite);
            return(createSprite);
        }
 public ScrollingBackgroundSprite(Viewport theViewport)
 {
     mBackgroundSprites = new List<ImageSprite>();
       mRightMostSprite = null;
       mLeftMostSprite = null;
       mViewport = theViewport;
 }
 private void setupPaddle()
 {
     paddle = new ImageSprite(imageURL: "ms-appx:///Images/paddle.png");
     SnapsEngine.AddSpriteToGame(paddle);
     paddleWidth = SnapsEngine.GameViewportWidth / 10.0;
     paddle.ScaleSpriteWidth(paddleWidth);
 }
Exemplo n.º 6
0
    public void StartProgram()
    {
        SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60);

        ImageSprite scaledCity = new ImageSprite(imageURL: "ms-appx:///Images/city.jpg");

        SnapsEngine.AddSpriteToGame(scaledCity);

        float maxWidth     = 500;
        float minWidth     = 100;
        float currentWidth = 100;
        float widthUpdate  = 1;

        while (true)
        {
            currentWidth = currentWidth + widthUpdate;
            if (currentWidth > maxWidth)
            {
                widthUpdate = -1;
            }
            if (currentWidth < minWidth)
            {
                widthUpdate = 1;
            }
            scaledCity.ScaleSpriteWidth(currentWidth);
            SnapsEngine.DrawGamePage();
        }
    }
Exemplo n.º 7
0
    public void StartProgram()
    {
        SnapsEngine.SetBackgroundColor(SnapsColor.Black);

        SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60);

        List <MovingSprite> sprites = new List <MovingSprite>();

        for (int i = 0; i < 100; i++)
        {
            ImageSprite starImage = new ImageSprite(imageURL: "ms-appx:///Images/star.png");
            SnapsEngine.AddSpriteToGame(starImage);
            starImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 75);
            FallingSprite star = new FallingSprite(sprite: starImage,
                                                   ySpeed: 15);
            sprites.Add(star);
        }

        while (true)
        {
            foreach (MovingSprite sprite in sprites)
            {
                sprite.Update();
            }
            SnapsEngine.DrawGamePage();
        }
    }
Exemplo n.º 8
0
        private void buttonListAnimation_Click(object sender, EventArgs e)
        {
            AnimatedDecoration listAnimation = new AnimatedDecoration(this.olvSimple);
            Animation          animation     = listAnimation.Animation;

            //Sprite image = new ImageSprite(Resource1.largestar);
            //image.FixedLocation = Locators.SpriteAligned(Corner.MiddleCenter);
            //image.Add(0, 2000, Effects.Rotate(0, 360 * 2f));
            //image.Add(1000, 1000, Effects.Fade(1.0f, 0.0f));
            //animation.Add(0, image);

            Sprite image = new ImageSprite(Resource1.largestar);

            image.Add(0, 500, Effects.Move(Corner.BottomCenter, Corner.MiddleCenter));
            image.Add(0, 500, Effects.Rotate(0, 180));
            image.Add(500, 1500, Effects.Rotate(180, 360 * 2.5f));
            image.Add(500, 1000, Effects.Scale(1.0f, 3.0f));
            image.Add(500, 1000, Effects.Goto(Corner.MiddleCenter));
            image.Add(1000, 900, Effects.Fade(1.0f, 0.0f));
            animation.Add(0, image);

            Sprite text = new TextSprite("Animations!", new Font("Tahoma", 32), Color.Blue, Color.AliceBlue, Color.Red, 3.0f);

            text.Opacity       = 0.0f;
            text.FixedLocation = Locators.SpriteAligned(Corner.MiddleCenter);
            text.Add(900, 900, Effects.Fade(0.0f, 1.0f));
            text.Add(1000, 800, Effects.Rotate(180, 1440));
            text.Add(2000, 500, Effects.Scale(1.0f, 0.5f));
            text.Add(3500, 1000, Effects.Scale(0.5f, 3.0f));
            text.Add(3500, 1000, Effects.Fade(1.0f, 0.0f));
            animation.Add(0, text);

            animation.Start();
        }
        //Adds a background sprite to be scrolled through the screen
        public void AddBackground(string theAssetName)
        {
            ImageSprite aBackgroundSprite = new ImageSprite();
              aBackgroundSprite.AssetName = theAssetName;

              mBackgroundSprites.Add(aBackgroundSprite);
        }
Exemplo n.º 10
0
    public void StartProgram()
    {
        SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60);

        ImageSprite squishyBall = new ImageSprite(imageURL: "ms-appx:///Images/ball.png");

        SnapsEngine.AddSpriteToGame(squishyBall);

        float maxWidth     = 500;
        float minWidth     = 100;
        float currentWidth = 100;
        float widthUpdate  = 1;

        while (true)
        {
            currentWidth = currentWidth + widthUpdate;
            if (currentWidth > maxWidth)
            {
                widthUpdate = -1;
            }
            if (currentWidth < minWidth)
            {
                widthUpdate = 1;
            }
            squishyBall.Width = currentWidth;
            SnapsEngine.DrawGamePage();
        }
    }
Exemplo n.º 11
0
 public AlienSprite(ImageSprite sprite, SpaceRocketsInSpaceGame game, double xSpeed, double ySpeed, RocketSprite target) :
     base(sprite: sprite, xSpeed: xSpeed, ySpeed: ySpeed)
 {
     gameValue   = game;
     originalX   = sprite.X;
     originalY   = sprite.Y;
     rocketValue = target;
 }
    private void setupBall()
    {
        ball = new ImageSprite(imageURL: "ms-appx:///Images/ball.png");
        SnapsEngine.AddSpriteToGame(ball);

        ballWidth = SnapsEngine.GameViewportWidth / 20.0;
        ball.ScaleSpriteWidth(ballWidth);
    }
 public FallingSprite(ImageSprite sprite, double xSpeed, double ySpeed, double viewportWidth, double viewportHeight) :
     base(sprite: sprite, xSpeed: xSpeed, ySpeed: ySpeed)
 {
     viewportWidthValue  = viewportWidth;
     viewportHeightValue = viewportHeight;
     spriteValue.Left    = (viewportWidthValue - spriteValue.Width) * spriteRand.NextDouble();
     spriteValue.Bottom  = viewportHeightValue * spriteRand.NextDouble();
 }
Exemplo n.º 14
0
        public SkillCard(System.Drawing.Bitmap cardImage, Vector2D position, string viewName, string cost, Data.Character ownerCharacter, Data.ActionSkill actionSkill)
        {
            this.cardImage      = cardImage;
            this.position       = position;
            this.ownerCharacter = ownerCharacter;
            this.cost           = cost;
            this.actionSkill    = actionSkill;

            {
                var bmp     = cardImage;
                var texture = new Texture(bmp);
                var w       = 160;
                var h       = (int)((double)bmp.Height / (double)bmp.Width * w);
                var sprite  = new ImageSprite(texture, new Rect(new Vector2D(position.X, position.Y), new Vector2D(w, h)), new Color(1, 1, 1, 1));
                layer.Add(sprite, 10);

                size           = new Vector2D(w, h);
                mySprites.face = sprite;
            }

            {
                var x    = position.X - 5;
                var y    = position.Y + 200;
                var font = new Font(Config.MainConfig.MainFontPath, 16, new Color(1, 1, 1, 1), new Font.FontFrame[] {
                    new Font.FontFrame(2, new Color(1, 0, 0, 0)),
                }, 0);
                var ts = new TextSprite(viewName, font, new Vector2D(x, y));

                layer.Add(ts, 20);
                mySprites.viewName = ts;
            }
            {
                var x      = position.X;
                var y      = position.Y + 227;
                var w      = size.X;
                var h      = 1;
                var sprite = new PlaneSprite(new Rect(new Vector2D(x, y), new Vector2D(w, h)), new Color(0.3, 1, 1, 1));
                layer.Add(sprite, 10);
                mySprites.bar = sprite;
            }
            {
                var x    = position.X - 5;
                var y    = position.Y + 225;
                var font = new Font(Config.MainConfig.MainFontPath, 12, new Color(1, 1, 1, 1), new Font.FontFrame[] {
                    new Font.FontFrame(2, new Color(1, 0, 0, 0)),
                }, 0);
                var ts = new TextSprite(cost, font, new Vector2D(x, y));
                //var ts = new TextSprite(cost, "data/font/rounded-mgenplus-1cp-medium.ttf", 12, new Vector2D(x, y), new Color(1, 1, 1, 1));
                layer.Add(ts, 20);
                mySprites.ViewStatus = ts;
            }

            {
                var sprite = new PlaneLineSprite(new Rect(position, size), new Color(0.5, 1, 1, 1));
                layer.Add(sprite, 30);
                mySprites.mouseOn = sprite;
            }
        }
Exemplo n.º 15
0
        private void AddStarAnimation(Animation animation, int start, float opacity)
        {
            Sprite sprite = new ImageSprite(Resource1.star32);

            sprite.Opacity = opacity;
            sprite.Add(0, 4000, Effects.Walk(Locators.AnimationBounds(), WalkDirection.Anticlockwise));
            sprite.Add(0, 4000, Effects.Rotate(0, 1480));
            animation.Add(start, sprite);
        }
Exemplo n.º 16
0
        public TalkScene(string talkScriptPath)
        {
            this.talkScriptPath = talkScriptPath;

            // 前回(今現在)の画面を取得
            {
                //var bmp = new System.Drawing.Bitmap("data/image/bg/酒場.png");
                var bmp     = WindowManager.ScreenShot();
                var texture = new Texture(bmp);
                var w       = 1600;
                var h       = (int)((double)bmp.Height / (double)bmp.Width * w);
                var sprite  = new ImageSprite(texture, new Rect(new Vector2D(0, 0), new Vector2D(w, h)), new Color(1, 1, 1, 1));
                layer.Add(sprite, 10000);

                sceneStartFadeImageSprite = sprite;
            }

            // 立ち絵のフェードで表示するための、イージングの数値を計算
            {
                fadeTimerSpline = new Emugen.Image.Animation.BSplineXtoY(
                    new Vector2D[] { new Vector2D(0, 0), new Vector2D(0, 1), new Vector2D(1, 1) },
                    100);
            }
            {
                slideTimerSpline = new Emugen.Image.Animation.BSplineXtoY(
                    new Vector2D[] { new Vector2D(0, 0), new Vector2D(0, 1), new Vector2D(1, 1) },
                    100);
            }

            // スクリプトの実行
            scriptAPI = new ScriptAPI();
            {
                var thread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadScriptRun));
                scriptAPI.thread = thread;
                thread.Start();
            }

            {
                var bmp     = new System.Drawing.Bitmap(Config.MainConfig.TalkScene.NextWaitIcon);
                var texture = new Texture(bmp);
                var w       = 30;
                var h       = (int)((double)bmp.Height / (double)bmp.Width * w);
                var sprite  = new ImageSprite(texture, new Rect(new Vector2D(1400 + 50, 600), new Vector2D(w, h)), new Color(1, 1, 1, 1));
                layer.Add(sprite, 200);

                ImageSpriteWaitEnterIcon = sprite;
            }

            {
                var sprite = new PlaneSprite(new Rect(new Vector2D(100, 600), new Vector2D(300, 40)), new Color(0.5, 0, 0, 0));
                layer.Add(sprite, 150);
            }
            {
                var sprite = new PlaneSprite(new Rect(new Vector2D(100, 650), new Vector2D((1600 - 200), 40 + 50 * 3)), new Color(0.5, 0, 0, 0));
                layer.Add(sprite, 150);
            }
        }
 public ChasingAlien(ImageSprite sprite, RocketSprite target,
                     double xAcceleration, double yAcceleration, double friction) :
     base(sprite: sprite, xSpeed: 0, ySpeed: 0, target: target)
 {
     rocketValue        = target;
     xAccelerationValue = xAcceleration;
     yAccelerationValue = yAcceleration;
     frictionValue      = friction;
 }
Exemplo n.º 18
0
        public TitleScene()
        {
            {
                var bmp     = new System.Drawing.Bitmap(Config.MainConfig.TitleScene.TitleBackgroundImage);
                var texture = new Texture(bmp);
                var w       = 1600;
                var h       = (int)((double)texture.Size.Y / (double)texture.Size.X * w);
                var sprite  = new ImageSprite(texture, new Rect(new Vector2D(0, 0), new Vector2D(w, h)), new Color(1, 1, 1, 1));
                layer.Add(sprite, 5);
            }

            {
                bgm = new SoundPlayer(Config.MainConfig.TitleScene.TitleBGM, 0.5f, true, Emugen.Sound.SoundPlayer.SoundType.BGM);
            }

            {
                var position = new Vector2D(0, 0);
                var font     = new Font(
                    Config.MainConfig.MainFontPath,
                    45,
                    new Color(1, 1, 1, 1),
                    new Font.FontFrame[] {
                    new Font.FontFrame(4, new Color(1, 0, 0.5, 1.0))
                },
                    5);
                var button = new UI.Common.Button("New Game", font, new Vector2D(0, 600), () => {
                    new Emugen.Sound.SoundPlayer(Config.MainConfig.TitleScene.SelectSE, 0.5f, false, Emugen.Sound.SoundPlayer.SoundType.SE);
                    bgm.Stop();
                    WindowManager.nextScene = new Scene.TalkScene(Config.MainConfig.TitleScene.NewGameStartScript);
                });
                layer.Add(button, 20);
                mySprites.ButtonNewGame = button;
            }

            {
                var position = new Vector2D(0, 0);
                var font     = new Font(
                    Config.MainConfig.MainFontPath,
                    45,
                    new Color(1, 1, 1, 1),
                    new Font.FontFrame[] {
                    new Font.FontFrame(4, new Color(1, 0, 0.5, 1.0))
                },
                    5);
                var button = new UI.Common.Button("Exit", font, new Vector2D(0, 600 + 100), () => {
                    new Emugen.Sound.SoundPlayer(Config.MainConfig.TitleScene.SelectSE, 0.5f, false, Emugen.Sound.SoundPlayer.SoundType.SE);
                    bgm.Stop();

                    Emugen.Thread.Sleep.Do(100);
                    Emugen.OpenTK.WindowManager.Close();
                });
                layer.Add(button, 20);
                mySprites.ButtonExit = button;
            }
        }
Exemplo n.º 19
0
        public RocketSprite(ImageSprite sprite,

                            SpaceRocketsInSpaceGame game,
                            double xSpeed, double ySpeed) :
            base(sprite, xSpeed, ySpeed)
        {
            originalX = sprite.X;
            originalY = sprite.Y;

            gameValue = game;
        }
Exemplo n.º 20
0
        public Area(PointF pos, Areas type, Image sprite = null, float scaleArea = 1, float scaleSprite = 1.05f)
        {
            this.Pos  = pos;
            this.Type = type;
            Shape     = new SquareShape(scaleArea);
            isDispose = false;

            if (sprite != null)
            {
                Sprite = new ImageSprite(sprite, PointOp.Mul(MainGame.CellSize, scaleSprite));
            }
        }
    public void StartProgram()
    {
        SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60);

        ImageSprite ball = new ImageSprite(imageURL: "ms-appx:///Images/ball.png");

        SnapsEngine.AddSpriteToGame(ball);

        while (true)
        {
            SnapsEngine.DrawGamePage();
        }
    }
        public EntityNet(float x, float y, int h, float v, int power, int range, bool isLarge)
            : base(x, y, h, v, power)
        {
            spriteSheet = new ImageSprite(Resources.LPull(NameSet.Entity.ENTITY_NET_THROWN), 1, 1, 1);

            Width  = 24;
            Height = 24;

            splashRange = rangeUnitToPixels(range);
            spriteSheet.setAnimationKey(0);

            largeNetSprite = isLarge;
            //Console.WriteLine("Initialised splash range: " + splashRange);
        }
        public EntityHarpoon(float x, float y, int h, float v, int power, int passThruNum, int key)
            : base(x, y, h, v, power)
        {
            spriteSheet = new ImageSprite(Resources.LPull(NameSet.Entity.ENTITY_HARPOON_FIRED), 1, 1, 1);

            spriteKey = key;

            //timeToAlive = 3000;

            passThruMax = passThruNum;

            Width  = 24;
            Height = 24;
        }
    public void StartProgram()
    {
        SnapsEngine.SetBackgroundColor(SnapsColor.Black);

        SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60);

        List <MovingSprite> sprites = new List <MovingSprite>();

        for (int i = 0; i < 100; i++)
        {
            ImageSprite starImage = new ImageSprite(imageURL: "ms-appx:///Images/star.png");
            SnapsEngine.AddSpriteToGame(starImage);
            starImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 75);
            FallingSprite star = new FallingSprite(sprite: starImage,
                                                   ySpeed: 15);
            sprites.Add(star);
        }

        ImageSprite rocketImage = new ImageSprite(imageURL: "ms-appx:///Images/SpaceRocket.png");

        SnapsEngine.AddSpriteToGame(rocketImage);
        rocketImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 15);
        rocketImage.CenterX = SnapsEngine.GameViewportWidth / 2.0;
        rocketImage.CenterY = SnapsEngine.GameViewportHeight / 2.0;

        RocketSprite rocket = new RocketSprite(sprite: rocketImage, xSpeed: 10, ySpeed: 10);

        sprites.Add(rocket);

        ImageSprite chasingAlienImage = new ImageSprite(imageURL: "ms-appx:///Images/purpleAlien.png");

        SnapsEngine.AddSpriteToGame(chasingAlienImage);
        chasingAlienImage.Top = 10;
        chasingAlienImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 20);
        chasingAlienImage.CenterX = SnapsEngine.GameViewportWidth / 2.0;
        chasingAlienImage.Top     = 0;
        ChasingAlien chaser = new ChasingAlien(sprite: chasingAlienImage, target: rocket, xAcceleration: .3, yAcceleration: .3, friction: 0.99);

        sprites.Add(chaser);

        while (true)
        {
            foreach (MovingSprite sprite in sprites)
            {
                sprite.Update();
            }
            SnapsEngine.DrawGamePage();
        }
    }
Exemplo n.º 25
0
 public override bool Draw()
 {
     if (MainMenu.IsVisible && IsVisible)
     {
         try
         {
             ImageSprite.Draw(new Vector2(Kalista.Menu["Language.Select"].Position.X + 365, Kalista.Menu["Language.Select"].Position.Y + 180));
         }
         catch
         {
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 26
0
 public override bool Draw()
 {
     if (MainMenu.IsVisible && IsVisible)
     {
         try
         {
             ImageSprite.Draw(new Vector2(Nasus.Menu["Language.Select"].Position.X + 412, Nasus.Menu["Language.Select"].Position.Y + 255));
         }
         catch
         {
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 27
0
 public override bool Draw()
 {
     if (MainMenu.IsVisible && IsVisible)
     {
         try
         {
             ImageSprite.Draw(new Vector2(TwistedFate.Menu["Language.Select"].Position.X - 14, TwistedFate.Menu["Language.Select"].Position.Y + 185));
         }
         catch
         {
         }
         return(true);
     }
     return(false);
 }
        public EntityStone(float x, float y, int h, float v, int power, int range, bool stun, int length, int key)
            : base(x, y, h, v, power)
        {
            spriteSheet = new ImageSprite(Resources.LPull(NameSet.Entity.ENTITY_STONE_THROWN), 1, 1, 1);

            Width  = 40;
            Height = 40;

            splashRange = rangeUnitToPixels(range);

            stunnable  = stun;
            stunLength = length;

            spriteKey = key;
            //Console.WriteLine("Initialised splash range: " + splashRange);
        }
Exemplo n.º 29
0
    public void StartProgram()
    {
        SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60);

        ImageSprite scaledBall = new ImageSprite(imageURL: "ms-appx:///Images/ball.png");

        SnapsEngine.AddSpriteToGame(scaledBall);

        scaledBall.Width  = SnapsEngine.GameViewportWidth;
        scaledBall.Height = SnapsEngine.GameViewportHeight;

        while (true)
        {
            SnapsEngine.DrawGamePage();
        }
    }
        public EntityBait(float x, float y, int h, float v, int range, int length, float mobSpeed, bool poisoned)
            : base(x, y, h, v, 0)
        {
            spriteSheet = new ImageSprite(Resources.LPull(NameSet.Entity.ENTITY_BAIT_THROWN), 1, 1, 1);

            Width  = 24;
            Height = 24;

            splashRange      = rangeUnitToPixels(range);
            stunLength       = length;
            affectedMobSpeed = mobSpeed;
            isPoisoned       = poisoned;
            //Console.WriteLine("Initialised splash range: " + splashRange);


            ttlCounter.Start();
        }
    public void StartProgram()
    {
        SnapsEngine.SetBackgroundColor(SnapsColor.Black);

        SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60);

        ImageSprite starImage = new ImageSprite(imageURL: "ms-appx:///Images/star.png");

        SnapsEngine.AddSpriteToGame(starImage);
        starImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 50);
        FallingSprite star = new FallingSprite(sprite: starImage, ySpeed: 1);

        while (true)
        {
            star.Update();
            SnapsEngine.DrawGamePage();
        }
    }
Exemplo n.º 32
0
        public override void AddElement(Data.Element element)
        {
            var elementNameToFilePath = new Dictionary <string, string>();

            foreach (var i in Config.MainConfig.Elements)
            {
                elementNameToFilePath.Add(i.Word, i.ImagePath);
            }

            var bmp     = new System.Drawing.Bitmap(elementNameToFilePath[element.Name]);
            var texture = new Texture(bmp);
            var w       = 30;
            var h       = (int)((double)bmp.Height / (double)bmp.Width * w);
            var sprite  = new ImageSprite(texture, new Rect(new Vector2D(0, 0), new Vector2D(w, h)), new Color(1, 1, 1, 1));

            layer.Add(sprite, 10);
            mySprites.element.Add(sprite);

            SetPosition(this.position);
        }
        //Update the posotin of the background images
        public void Update(GameTime theGameTime, int theSpeed, HorizontalScrollDirection theDirection)
        {
            if (theDirection == HorizontalScrollDirection.Left)
              {
            //Check to see if any of the Background sprites have moved off the screen
            //if they have, then move them to the right of the chain of scrolling backgrounds
            foreach (ImageSprite aBackgroundSprite in mBackgroundSprites)
            {
              if (aBackgroundSprite.Position.X < mViewport.X - aBackgroundSprite.Size.Width)
              {
            aBackgroundSprite.Position = new Vector2(mRightMostSprite.Position.X + mRightMostSprite.Size.Width, mViewport.Y);
            mRightMostSprite = aBackgroundSprite;
              }
            }
              }
              else if (theDirection == HorizontalScrollDirection.Right)
              {
            //Check to see if any of the background images have moved off the screen
            //if they have, then move them to the left of the chain of scrolling backgrounds
            foreach (ImageSprite aBackgroundSprite in mBackgroundSprites)
            {
              if (aBackgroundSprite.Position.X > mViewport.X + mViewport.Width)
              {
            aBackgroundSprite.Position = new Vector2(mLeftMostSprite.Position.X - mLeftMostSprite.Size.Width, mViewport.Y);
            mLeftMostSprite = aBackgroundSprite;
              }
            }
              }

              //Set the Direction based on movement to the left or right that was passed in
              Vector2 aDirection = Vector2.Zero;
              if (theDirection == HorizontalScrollDirection.Left)
              {
            aDirection.X = -1;
              }
              else if (theDirection == HorizontalScrollDirection.Right)
              {
            aDirection.X = 1;
              }

              //Update the postions of each of the Background sprites
              foreach (ImageSprite aBackgroundSprite in mBackgroundSprites)
              {
            aBackgroundSprite.Update(theGameTime, new Vector2(theSpeed, 0), aDirection);
              }
        }
        public override void LoadContent(ContentManager theContentManager)
        {
            //Clear the Sprites currently stored as the left and right ends of the chain
              mRightMostSprite = null;
              mLeftMostSprite = null;

              //The total width of all the sprites in the chain
              float aWidth = 0;

              //Cycle through all of the Background sprites that have been added
              //and load their content and position them.
              foreach (ImageSprite aBackgroundSprite in mBackgroundSprites)
              {
            //Load the sprite's content and apply it's scale, the scale is calculate by figuring
            //out how far the sprite needs to be stretech to make it fill the height of the viewport
            aBackgroundSprite.LoadContent(theContentManager, aBackgroundSprite.AssetName);
            aBackgroundSprite.Scale = mViewport.Height / aBackgroundSprite.Size.Height;

            //If the Background sprite is the first in line, then mLastInLine will be null.
            if (mRightMostSprite == null)
            {
              //Position the first Background sprite in line at the (0,0) position
              aBackgroundSprite.Position = new Vector2(mViewport.X, mViewport.Y);
              mLeftMostSprite = aBackgroundSprite;
            }
            else
            {
              //Position the sprite after the last sprite in line
              aBackgroundSprite.Position = new Vector2(mRightMostSprite.Position.X + mRightMostSprite.Size.Width, mViewport.Y);
            }

            //Set the sprite as the last one in line
            mRightMostSprite = aBackgroundSprite;

            //Increment the width of all the sprites combined in the chain
            aWidth += aBackgroundSprite.Size.Width;
              }

              //If the Width of all the sprites in the chain does not fill the twice the Viewport width
              //then we need to cycle through the images over and over until we have added
              //enough background images to fill the twice the width.
              int aIndex = 0;
              if (mBackgroundSprites.Count > 0 && aWidth < mViewport.Width * 2)
              {
            do
            {
              //Add another background image to the chain
              ImageSprite aBackgroundSprite = new ImageSprite();
              aBackgroundSprite.AssetName = mBackgroundSprites[aIndex].AssetName;
              aBackgroundSprite.LoadContent(theContentManager, aBackgroundSprite.AssetName);
              aBackgroundSprite.Scale = mViewport.Height / aBackgroundSprite.Size.Height;
              aBackgroundSprite.Position = new Vector2(mRightMostSprite.Position.X + mRightMostSprite.Size.Width, mViewport.Y);
              mBackgroundSprites.Add(aBackgroundSprite);
              mRightMostSprite = aBackgroundSprite;

              //Add the new background Image's width to the total width of the chain
              aWidth += aBackgroundSprite.Size.Width;

              //Move to the next image in the background images
              //If we've moved to the end of the indexes, start over
              aIndex += 1;
              if (aIndex > mBackgroundSprites.Count - 1)
              {
            aIndex = 0;
              }

            } while (aWidth < mViewport.Width * 2);
              }
        }