コード例 #1
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(1, 1);
            Console.SetBufferSize(80, 25);
            Console.SetWindowSize(80, 25);

            Walls walls = new Walls(80, 25);

            walls.Draw();

            // Отрисовка точек
            Point1 p     = new Point1(4, 5, '*');
            Snake  snake = new Snake(p, 4, Direction.RIGHT);

            snake.Draw();

            FoodCreator foodCreator = new FoodCreator(80, 25, '$');
            Point1      food        = foodCreator.CreateFood();

            food.Draw();

            while (true)
            {
                if (walls.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Draw();
                }
                else
                {
                    snake.Move();
                }

                Thread.Sleep(100);
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
            }
        }
コード例 #2
0
ファイル: Snake.cs プロジェクト: lihac92/snake
        internal void Move()
        {
            Point1 tail = pList.First();

            pList.Remove(tail);
            Point1 head = GetNextPoint();

            pList.Add(head);

            tail.Clear();
            head.Draw();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Point1 p1 = new Point1();

            p1.x   = 1;
            p1.y   = 3;
            p1.sym = '*';

            p1.Draw();

            Point1 p2 = new Point1();

            p2.x   = 4;
            p2.y   = 5;
            p2.sym = '#';

            p2.Draw();

            Console.ReadLine();
        }