Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(56, 25);
            Console.SetBufferSize(56, 25);
            Console.CursorVisible = false;
            MainMenu mainMenu = new MainMenu();

            mainMenu.Options();
            mainMenu.Begin();
        }
Esempio n. 2
0
        public void Start()
        {
            DrawGameView();
            DrawScore();
            DrawLevel();
            snake.Draw();
            food.Draw();
            wall.Draw();
            Thread thread = new Thread(MoveSnake);

            thread.Start();
            while (isAlive)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                if (snake.SnakeMovement(keyInfo))
                {
                    snake.ChangeDirection(keyInfo);
                }

                if (keyInfo.Key == ConsoleKey.Escape)
                {
                    thread.Abort();
                    string fileName = Nickname + ".xml";
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }
                    FileStream    fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                    XmlSerializer xs = new XmlSerializer(typeof(List <GameObject>));
                    xs.Serialize(fs, g_objects);
                    fs.Close();
                    MainMenu mainMenu = new MainMenu();
                    mainMenu.Options();
                    mainMenu.Begin();
                }
            }
        }