public bool CheckCollideWithBird(Bird StupidBird) { for (int i = 0; i < NumberOfPipe; i++) { Rectangle rectangle = new Rectangle((int)StupidBird.Position.X, (int)StupidBird.Position.Y - 5, 60, 42); if (rectangle.Intersects(new Rectangle((int)q_pipe1.ElementAt<Pipe>(i).Position.X + 35, (int)q_pipe1.ElementAt<Pipe>(i).Position.Y + 20, 100, 615))) { q_pipe2.ElementAt<Pipe>(i).CanScore = false; return true; } Rectangle rectangle2 = new Rectangle((int)StupidBird.Position.X, (int)StupidBird.Position.Y - 20, 60, 42); if (rectangle.Intersects(new Rectangle((int)q_pipe2.ElementAt<Pipe>(i).Position.X + 35, (int)q_pipe2.ElementAt<Pipe>(i).Position.Y, 100, 615))) { q_pipe2.ElementAt<Pipe>(i).CanScore = false; return true; } } return false; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here bg_game1 = Content.Load<Texture2D>("img/bg_game1"); bg_game = Content.Load<Texture2D>("img/bg_game"); soundPoint = Content.Load<SoundEffect>("sound/sfx_point"); soundWing = Content.Load<SoundEffect>("sound/sfx_wing"); soundDie = Content.Load<SoundEffect>("sound/sfx_die"); soundhit = Content.Load<SoundEffect>("sound/sfx_hit"); footer = new Footer(Content, spriteBatch); pipeControl = new PipeControl(Content, spriteBatch); bird1 = Content.Load<Texture2D>("img/bird1"); fontScore = Content.Load<SpriteFont>("SpriteFont1"); StupidBird = new Bird(Content, spriteBatch); BtnRetry = Content.Load<Texture2D>("img/btn-play"); GameoverTexture = Content.Load<Texture2D>("img/gameover"); }