private void startSingle_Click(object sender, EventArgs e) { singlePlayer SP = new singlePlayer(s, snake, back, name.Text); this.Hide(); SP.ShowDialog(); this.Close(); }
private void formSnake_KeyDown(object sender, KeyEventArgs e) { if (!moveDone) { if (e.KeyCode == Keys.Up || e.KeyValue == 87) { snake.setDirection("up"); } else if (e.KeyCode == Keys.Down || e.KeyValue == 83) { snake.setDirection("down"); } else if (e.KeyCode == Keys.Left || e.KeyValue == 65) { snake.setDirection("left"); } else if (e.KeyCode == Keys.Right || e.KeyValue == 68) { snake.setDirection("right"); } moveDone = true; } if (e.KeyValue == 82 && game.T.Enabled) { singlePlayer newGame = new singlePlayer(snake.Speed, snake.Color.Color, sketch.BackColor, food.Color[1].Color, snake.Name); this.Hide(); newGame.ShowDialog(); this.Close(); } else if (e.KeyValue == 27 || e.KeyValue == 81) { snakeUpdate.Enabled = false; DateTime stop = DateTime.Now; if (MessageBox.Show("Are you sure?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { this.Close(); } snakeUpdate.Enabled = true; food.Time = food.Time + (DateTime.Now - stop); } }