private void CalculateScore(Tube tube)
 {
     if (bird.passing(tube))
     {
         score++;
         lbScore.Text = score.ToString();
     }
 }
Beispiel #2
0
 public void Initialize()
 {
     bird      = new Player(150, 200);
     tube1     = new Tube(500, -100, true);
     tube2     = new Tube(500, 300);
     this.Text = "Flappy Bird Score : 0";
     gravity   = 0;
     timer1.Start();
 }
Beispiel #3
0
 private void CreateNewTubes()
 {
     if (tube1.x < bird.x - 300)
     {
         Random random = new Random();
         int    y1     = random.Next(-200, 000);
         tube1 = new Tube(500, y1, true);
         tube2 = new Tube(500, y1 + 400);
         bird.score++;
         this.Text = "Flappy Bird Score : " + bird.score;
     }
 }
        private void AddTubes()
        {
            const int LEFT_MOST = WIDTH + GAP_BETWEEN_BIRD_FIRST_TUBE;

            for (int i = 0; i < NUMBER_OF_TUBEPARIR * 2; i++)
            {
                bool isUp       = i % 2 == 0;
                int  delheight  = (int)Math.Pow(-1, i % 2) * 10 * (i % 3);
                int  pairNumber = i / 2;

                Tube tube = new Tube(LEFT_MOST - pairNumber * GAP, Tube.HEIGHT + delheight, isUp);
                this.Controls.Add(tube);
            }
        }
Beispiel #5
0
        private bool Collide(Player bird, Tube tube1)
        {
            PointF delta = new PointF();

            delta.X = (bird.x + bird.size / 2) - (tube1.x + tube1.widht / 2);
            delta.Y = (bird.y + bird.size / 2) - (tube1.y + tube1.height / 2);
            if (Math.Abs(delta.X) <= bird.size / 2 + tube1.widht / 2)
            {
                if (Math.Abs(delta.Y) <= bird.size / 2 + tube1.height / 2)
                {
                    return(true);
                }
            }
            return(false);
        }