Example #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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // TODO: Add your update logic here
            mMouseIconSprite.Update();
            player.Update(gameTime, graphics);
            MouseState ms = Mouse.GetState();

            UpdateFire(ms, gameTime);
            SpawnEnemy(gameTime);
            foreach (Fire a in balls) // Loop through List with foreach
            {
                a.Update(gameTime);
            }
            foreach (Enemy a in enemies) // Loop through List with foreach
            {
                a.Update(gameTime, player.Position, player.Size);
            }
            removeLostBalls();
            checkFireEnemyCollision();
            base.Update(gameTime);
        }
Example #2
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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // TODO: Add your update logic here
            //Fuel change
            if (!player.Position.Equals(oldposition))
            {
                mFuelbar.changeFuel(-1);
            }
            oldposition = player.Position;
            mMouseIconSprite.Update();
            player.Update(gameTime, graphics);
            MouseState ms = Mouse.GetState();

            UpdateFire(ms, gameTime);
            SpawnEnemy(gameTime);
            foreach (Fire a in balls) // Loop through List with foreach
            {
                a.Update(gameTime);
            }
            foreach (Enemy a in enemies) // Loop through List with foreach
            {
                if (!checkEnemyPlayerCollision(a))
                {
                    a.Update(gameTime, player.Position, player.Size);
                }
            }
            removeLostBalls();
            checkFireEnemyCollision();

            //Change health on contact
            if (checkEnemyPlayerCollision(null))
            {
                mHealthbar.changeHealth(-1);
            }

            base.Update(gameTime);
        }