Beispiel #1
0
 public void CollisionDetectionZomFollow(ZombieFollow zomFollow, int viewportWidth, int viewportHeight, Rectangle bulletRectangle)
 {
     if (bulletRectangle.Intersects(zomFollow.zomFollowRectangle) && bulletAlive == true)
     {
         zomFollow.zomFollowHit = true;
         zomFollow.Respawn(random, viewportWidth, viewportHeight);
         bulletAlive = false;
         //Score increases when collision between zombies and bullet occurs
         score = score + 1;
     }
 }
Beispiel #2
0
        //Calculates player collision with the zombies calling its respawn method
        public void CollsionDetectionZomFollow(ZombieFollow zomFollow, int viewportWidth, int viewportHeight, Bullet bullet)
        {
            Rectangle playerRectangle =
                new Rectangle((int)playerPosition.X, (int)playerPosition.Y,
                              mSpriteTexture.Width, mSpriteTexture.Height);



            if (playerRectangle.Intersects(zomFollow.zomFollowRectangle) && zomFollow.zomFollowHit == false)
            {
                zomFollow.zomFollowHit = true;

                zomFollow.Respawn(random, viewportWidth, viewportHeight);

                playerAlive = false;
                Respawn(viewportWidth, viewportHeight);
                playerHit    = true;
                bullet.score = 0;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            viewportHeight = graphics.GraphicsDevice.Viewport.Height;
            viewportWidth  = graphics.GraphicsDevice.Viewport.Width;



            random = new Random();

            bullet1 = new Bullet();
            aPlayer = new Player();
            aPlayer.screenBounds = graphics.GraphicsDevice.Viewport.Bounds;

            zomFollow[0] = new ZombieFollow(random);
            zomFollow[1] = new ZombieFollow(random);

            zomRandom[0] = new ZombieRandom(random);
            zomRandom[1] = new ZombieRandom(random);
            base.Initialize();
        }