private void ViewLoop(object obj, EventArgs args) { var nextBitmap = controller.GetNextBitmap(GameMapPictureBox.Size); if (nextBitmap != null) { GameMapPictureBox.Image = nextBitmap; ScoresLabel.Text = controller.GetScores(); } else { timer.Stop(); if (controller.GetGameResult()) { GameResultLabel.Text = "Ты победил!"; } else { GameResultLabel.Text = "Ты проиграл!"; } GameResultLabel.Visible = true; StartButton.Enabled = true; controller.Initial(); GameMapPictureBox.Image = controller.GetNextBitmap(GameMapPictureBox.Size); ScoresLabel.Text = controller.GetScores(); MenuImage.Show(); StartButton.Show(); StartButton.Select(); } }
public GameForm(int width, int height, int tanksValue, int appleValue) { this.width = width - width % 15; this.height = height - height % 15; InitializeComponent(); controller = new PackmanController(); ClientSize = new Size(this.width, this.height + 30); MinimumSize = new Size(this.width + 16, this.height + 69); GameMapPictureBox.Size = new Size(this.width, this.height); GameMapPictureBox.Location = new Point(0, 30); timer.Interval = 50; timer.Tick += ViewLoop; controller.Initial(tanksValue, appleValue, GameMapPictureBox.Size); GameMapPictureBox.Image = controller.GetNextBitmap(GameMapPictureBox.Size); informationForm = new InformationForm(controller.GetInformationSource()); }