示例#1
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            pad = GamePad.GetState(PlayerIndex.One);
            key = Keyboard.GetState();
            maincharacter.Move(key);
            maincharacter.Move(pad, Content);

            if (oldpad.Buttons.Y == ButtonState.Released && pad.Buttons.Y == ButtonState.Pressed)
            {
                Shoot();
            }

            //bullets get shot
            for (int i = 0; i < bullets.Count; i++)
            {
                bullets[i].BulletMove();
            }

            //checks if yahweh has died
            for (int i = 0; i < enemymushi.Length; i++)
            {
                if (enemymushi[i].getRec().Intersects(maincharacter.getRec()))
                {
                    break;
                }
            }


            //mushies move to yahweh
            for (int i = 0; i < enemymushi.Length; i++)
            {
                enemymushi[i].MoveTowardsYaweh(maincharacter);
            }

            //checks if bullets hit an enemy
            for (int i = 0; i < bullets.Count; i++)
            {
                for (int j = 0; j < enemymushi.Length; j++)
                {
                    if (bullets[i].getRec().Intersects(enemymushi[j].getRec()))
                    {
                        bulletnumber = j;
                        bullets.RemoveAt(i);
                        Unspawn();
                        break;
                    }
                }
            }


            //oldpad is set to current pad
            oldpad = pad;
            base.Update(gameTime);
        }
示例#2
0
        public void MoveTowardsYaweh(Yahweh player)
        {
            if (yawehrec.X > player.getRec().X)
            {
                yawehrec.X -= 1;
            }
            if (yawehrec.X < player.getRec().X)
            {
                yawehrec.X += 1;
            }

            if (yawehrec.Y > player.getRec().Y)
            {
                yawehrec.Y -= 1;
            }

            if (yawehrec.Y < player.getRec().Y)
            {
                yawehrec.Y += 1;
            }
        }