public void CollisionDetectionZomRandom(ZombieRandom zomRandom, int viewportWidth, int viewportHeight, Rectangle bulletRectangle) { if (bulletRectangle.Intersects(zomRandom.zomRandomRectangle) && bulletAlive == true) { zomRandom.zomRandomHit = true; zomRandom.Respawn(random, viewportWidth, viewportHeight); bulletAlive = false; score = score + 1; } }
public void CollisionDetectionZomRandom(ZombieRandom zomRandom, int viewportWidth, int viewportHeight, Bullet bullet) { Rectangle playerRectangle = new Rectangle((int)playerPosition.X, (int)playerPosition.Y, mSpriteTexture.Width, mSpriteTexture.Height); if (playerRectangle.Intersects(zomRandom.zomRandomRectangle)) { zomRandom.zomRandomHit = true; zomRandom.Respawn(random, viewportWidth, viewportHeight); playerAlive = false; Respawn(viewportWidth, viewportHeight); playerHit = true; bullet.score = 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(); }