private void Game_Tick(object sender, EventArgs e) { if (birds.Count == 0) { NextGeneration(); tempBirds.Clear(); if (CounterLabelData > HighScoreLabelData) { HighScoreLabelData = CounterLabelData; HighScoreLabel.Text = "High:" + HighScoreLabelData.ToString(); } CounterLabelData = 0; CounterLabel.Text = CounterLabelData.ToString(); } PopulationLabelData = birds.Count; PopulationLabel.Text = "Live:" + PopulationLabelData.ToString(); Invalidate(); Gravity(); DetectCollusion(); MovePipes(); DetectOffScreenPipes(); Play(); }
private void InitializeLabels() { this.CounterLabel = new Label(); this.CounterLabel.Top = 5; this.CounterLabel.Left = this.Width - 90; this.CounterLabel.Font = new Font(FontFamily.GenericSerif, 21); this.CounterLabel.ForeColor = Color.Black; this.CounterLabel.SizeChanged += labelResize; this.CounterLabelData = 0; this.CounterLabel.BackColor = Color.Transparent; this.CounterLabel.AutoSize = true; this.CounterLabel.Text = CounterLabelData.ToString(); this.HighScoreLabel = new Label(); this.HighScoreLabel.Top = 35; this.HighScoreLabel.Left = this.Width - 135; this.HighScoreLabel.Font = new Font(FontFamily.GenericSerif, 21); this.HighScoreLabel.ForeColor = Color.Black; this.HighScoreLabel.SizeChanged += labelResize2; this.HighScoreLabelData = 0; this.HighScoreLabel.BackColor = Color.Transparent; this.HighScoreLabel.AutoSize = true; this.HighScoreLabel.Text = "High:" + HighScoreLabelData.ToString(); this.GenerationLabel = new Label(); this.GenerationLabel.Top = 70; this.GenerationLabel.Left = this.Width - 135; this.GenerationLabel.Font = new Font(FontFamily.GenericSerif, 21); this.GenerationLabel.ForeColor = Color.Black; this.GenerationLabel.SizeChanged += labelResize3; this.GenerationLabelData = 0; this.GenerationLabel.BackColor = Color.Transparent; this.GenerationLabel.AutoSize = true; this.GenerationLabel.Text = "Gen:" + GenerationLabelData.ToString(); this.PopulationLabel = new Label(); this.PopulationLabel.Top = 105; this.PopulationLabel.Left = this.Width - 135; this.PopulationLabel.Font = new Font(FontFamily.GenericSerif, 21); this.PopulationLabel.ForeColor = Color.Black; this.PopulationLabelData = 0; this.PopulationLabel.BackColor = Color.Transparent; this.PopulationLabel.AutoSize = true; this.PopulationLabel.Text = "Live:" + PopulationLabelData.ToString(); }