Example #1
0
 private void Window_Closed(object sender, EventArgs e)
 {
     if (flappy != null)
     {
         flappy.Shutdown();
     }
 }
Example #2
0
        public void life(flappyBaseClass bottomPipe, flappyBaseClass topPipe)
        {
            try
            {
                Rect bottom     = new Rect(bottomPipe.GetLeft, bottomPipe.GetTop, bottomPipe.ActualWidth, bottomPipe.ActualHeight);
                Rect top        = new Rect(topPipe.GetLeft, topPipe.GetTop, topPipe.ActualWidth, topPipe.ActualHeight);
                Rect flappybird = new Rect(flappy.GetLeft, flappy.GetTop, flappy.ActualWidth - 10, flappy.ActualHeight - 10);

                Rect addScore = new Rect(bottomPipe.GetLeft, topPipe.GetTop, 50, 600);

                if (addScore.IntersectsWith(flappybird))
                {
                    if (!score.HasContent)
                    {
                        score.Content = '1';
                    }
                    else
                    {
                        if (flappy.isAlive())
                        {
                            score.Content = int.Parse(score.Content.ToString()) + 1;
                        }
                    }
                }

                if (bottom.IntersectsWith(flappybird) || top.IntersectsWith(flappybird) || !flappy.isAlive())
                {
                    topPipe.Shutdown();
                    bottomPipe.Shutdown();

                    flappy.isAlive(false);
                    flappy.Shutdown();
                    this.lifeThread.Abort();
                    close.Visibility = System.Windows.Visibility.Visible;
                }
            }
            catch (Exception e)
            {
                //throw e;
            }
        }