public override void Update()
        {
            Trooper b = StarTrooperGame.Trooper;

            Vector2 v = new Vector2(b.Position.X - Position.X, b.Position.Y - Position.Y);

            v.Normalize();

            Velocity = v;

            if (v.X >= 0)
            {
                SpriteEffect = SpriteEffects.None;
            }
            else
            {
                SpriteEffect = SpriteEffects.FlipHorizontally;
            }
        }
Example #2
0
        public void LoadResources()
        {
            #region Background
            //Type the code here to add the background to the game.

            Texture2D background = Content.Load <Texture2D>(@"Pictures\background");

            Background bg = new Background(background);

            bg.Position = new Vector2(0, BackBufferHeight / 2);
            bg.ScaleX   = BackBufferWidth / background.Width;
            bg.ScaleY   = BackBufferHeight / background.Height;
            bg.ZOrder   = 10;
            bg.Origin   = Vector2.Zero;
            bg.Velocity = new Vector2(0, 1);

            m_AddedSprites.Add(bg);

            Background bg2 = (Background)bg.Clone();
            bg2.Position = new Vector2(0, -BackBufferHeight / 2);
            bg2.ScaleX   = BackBufferWidth / background.Width;
            bg2.ScaleY   = BackBufferHeight / background.Height;
            bg2.ZOrder   = 10;

            m_AddedSprites.Add(bg2);

            #endregion

            #region Trooper
            //Type the code here to add the Trooper sprite.
            Trooper trooper = new Trooper(Content.Load <Texture2D>(@"Pictures\TrooperSpritesheet"), 6, true);

            trooper.Position = new Vector2(BackBufferWidth / 2, BackBufferHeight - (ScreenBuffer * 3));
            trooper.Speed    = 4;
            m_AddedSprites.Add(trooper);

            Trooper = trooper;
            #endregion

            #region Condor
            //Type the code here to add the Condor sprite.
            Condor condor = new Condor();

            Animation condorAnimation = new Animation(Content.Load <Texture2D>(@"Pictures\CondorSpritesheet"), 4);

            condorAnimation.Play();
            condorAnimation.Loop = true;

            int[]     ExplosionDelay  = { 4, 3, 4 };
            Animation condorExplosion = new Animation(Content.Load <Texture2D>(@"Pictures\CondorExplosionSpritesheet"), 3, ExplosionDelay);

            condorExplosion.Play();

            condor.AddAnimation(condorAnimation);
            condor.AddAnimation(condorExplosion);
            Condor = condor;

            #endregion

            #region Fire
            Fire        = new Fire(Content.Load <Texture2D>(@"Pictures\FireSpritesheet"), 2, true);
            Fire.ZOrder = -10;
            #endregion
        }