private void GameScreen_KeyDown(object sender, KeyEventArgs e) { bool? correct = null; // (datatype)? specifies a version of that datatype that can have the value null string key = e.KeyData.ToString(); if (key == "Escape") { this.Close(); } if (!CoverLabel1.Visible) { switch (key) { case "A": correct = Q1.CheckAnswer(LeftAnswer1.Text); break; case "D": correct = Q1.CheckAnswer(RightAnswer1.Text); break; case "W": correct = Q1.CheckAnswer(UpAnswer1.Text); break; case "S": correct = Q1.CheckAnswer(DownAnswer1.Text); break; } if (correct != null) { if (correct == true) { CoverLabel1.Text = GoodText[r.Next(0, 6)]; CoverLabel1.ForeColor = Color.Green; car1.X += 2; car1.Speed = 4; } else { CoverLabel1.Text = BadText[r.Next(0, 6)]; CoverLabel1.ForeColor = Color.Red; car1.X += 1; car1.Speed = 1; if (_sfx) { SystemSounds.Hand.Play(); } } CoverLabel1.Show(); questionTimer1.Stop(); TPQList1.Add(questionTimer1.Elapsed.TotalSeconds); return; } } if (!CoverLabel2.Visible) { switch (key) { case "Left": correct = Q2.CheckAnswer(LeftAnswer2.Text); break; case "Right": correct = Q2.CheckAnswer(RightAnswer2.Text); break; case "Up": correct = Q2.CheckAnswer(UpAnswer2.Text); break; case "Down": correct = Q2.CheckAnswer(DownAnswer2.Text); break; } if (correct != null) { if (correct == true) { CoverLabel2.Text = GoodText[r.Next(0, 6)]; CoverLabel2.ForeColor = Color.Green; car2.X += 2; car2.Speed = 4; } else { CoverLabel2.Text = BadText[r.Next(0, 6)]; CoverLabel2.ForeColor = Color.Red; car2.X += 1; car2.Speed = 1; if (_sfx) { SystemSounds.Hand.Play(); } } CoverLabel2.Show(); questionTimer2.Stop(); TPQList2.Add(questionTimer2.Elapsed.TotalSeconds); return; } } }