static void Main(string[] args) { if (args.Length == 0) { SnakeGameManager.Play(); } else if (args.Length == 2) { int.TryParse(args[0], out int width); int.TryParse(args[1], out int height); SnakeGameManager.Play(width, height); } else if (args.Length == 3) { int.TryParse(args[0], out int width); int.TryParse(args[1], out int height); int.TryParse(args[2], out int fruitcount); SnakeGameManager.Play(width, height, fruitcount); } else if (args.Length == 4) { int.TryParse(args[0], out int width); int.TryParse(args[1], out int height); int.TryParse(args[2], out int fruitcount); int.TryParse(args[3], out int deltaTime); SnakeGameManager.Play(width, height, fruitcount, deltaTime); } }
public MainForm() { InitializeComponent(); _snakeGameManager = SnakeGameManager.Instance(this.CreateGraphics(), Size); _snakeGameManager.SnakeColided += OnSnakeColided; refresh_timer.Start(); }
public static SnakeGameManager Instance(Graphics graphics, SizeF screenSize) { if (_snakeGameManager == null) { lock (_lock) { if (_snakeGameManager == null) { _snakeGameManager = new SnakeGameManager(graphics, screenSize); } } } return(_snakeGameManager); }