Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
#if DEBUG
            PerformanceTimer.StartTimer("Time to update in ticks: ");
#endif
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
            Input.Update();
            // TODO: Add your update logic here
            InternalUpdate(); // <- Added Sprite update function here

            SpawnElapsedTime += gameTime.ElapsedGameTime;
            if (SpawnElapsedTime > CondorSpawnRate)
            {
                Condor condor = (Condor)Condor.Clone();
                condor.Position = new Vector2(RandomBetween(-100, m_BackBufferWidth + 100), -150);
                m_AddedSprites.Add(condor);
                SpawnElapsedTime = TimeSpan.Zero;
            }


            //test to change the button \ key used for firing trooper fireballs
            if (Input.ChangeTrooperFireButton())
            {
                Input.FireButton    = Keys.LeftShift;
                Input.AltFireButton = Buttons.RightTrigger;
            }

            //Save settings
            if (Input.SaveSettingsKey())
            {
                FileManager.SaveKeyMappings();
            }

            ScoreText.Text = "Score: " + score.ToString();
            ShotsText.Text = "Shots: " + shots.ToString();

            base.Update(gameTime);
#if DEBUG
            PerformanceTimer.StopTimer("Time to update in ticks: ");
#endif
        }
Exemplo n.º 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
        }
 protected Condor(Condor condor) : base(condor)
 {
 }