private void btnNewGame_Click(object sender, EventArgs e) { HungrySnakeGame form2 = new HungrySnakeGame(); form2.ShowDialog(); pictureBox1.Hide(); }
private void timer2_Tick(object sender, EventArgs e) { Graphics g = Graphics.FromImage(doubleBuffer); g.Clear(Color.LightCyan); g.DrawImage(backGround, 25, 50, 450, 300); Snake.Move(); if (Snake.GameOver()) { timer2.Stop(); timer2.Dispose(); DialogResult result = MessageBox.Show(string.Format("You Lose!\n You have {0} points for {1:0.00} seconds \n Do you want to play another one ?", Snake.points, (float)sw.Elapsed.TotalSeconds), "Do you want to play another game ? ", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { this.Close(); this.Hide(); HungrySnakeGame form2 = new HungrySnakeGame(); form2.ShowDialog(); } if (result == DialogResult.No) { timer2.Start(); sw.Start(); pause = false; this.Close(); } } Snake.Put(g); Snake.Draw(g); lblPoints.Text = Snake.points.ToString(); lblTime.Text = string.Format("{0:0.00}", sw.Elapsed.TotalSeconds); graphics.DrawImageUnscaled(doubleBuffer, 0, 0); }
private void pictureBox1_Click_1(object sender, EventArgs e) { HungrySnakeGame form2 = new HungrySnakeGame(); form2.ShowDialog(); }