Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.SetBufferSize(80, 25);

            Walls walls = new Walls(80, 25);

            walls.Draw();

            Point p     = new Point(4, 5, '*');
            Snake snake = new Snake(p, 4, Direction.RIGHT);

            snake.Drow();

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

            food.Drow();

            while (true)
            {
                if (walls.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }

                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Drow();
                }
                else
                {
                    snake.Move();
                }

                Thread.Sleep(100);

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.Title = "Snake";

            Walls walls = new Walls(Width, Height);

            walls.Draw();

            Snake snake = new Snake(new Point(50, 25, '*', ConsoleColor.Green), 10, Direction.Right);

            snake.Drow();

            FoodCreator foodCreator = new FoodCreator(Console.BufferWidth, Console.BufferHeight, '@');
            Point       foodItem    = foodCreator.Create(snake);

            foodItem.Drow();

            while (true)
            {
                if (walls.IsHit(snake) || snake.IsHitTail())
                {
                    StopGame();
                    Console.ReadKey();
                    break;
                }
                if (snake.Eat(foodItem))
                {
                    foodItem = foodCreator.Create(snake);
                    foodItem.Drow();
                    snake.ShowScore();
                }
                else
                {
                    snake.Move();
                }
                Thread.Sleep(100 - (snake.Score));
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Point p1 = new Point(1, 3, '*');

            p1.Drow();

            Point p2 = new Point(4, 5, '#');

            p2.Drow();
            Console.ReadLine();
        }
Esempio n. 4
0
        internal void Move()
        {
            Point tail = pList.First();

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

            pList.Add(head);

            tail.Clear();
            head.Drow();
        }
Esempio n. 5
0
        public void Move()
        {
            Point tail = pLine.First();

            pLine.Remove(tail);
            Point head = GetNextPoint();

            pLine.Add(head);

            tail.Clear();
            head.Drow();
        }
Esempio n. 6
0
        public bool Eat(Point eats_point)
        {
            Point next_point = GetNextPoint();
            if (next_point.isHit(eats_point))
            {
                eats_point.sym = next_point.sym;
                eats_point.Drow();
                points.Add(eats_point);
                return true;
            }
            else return false;

        }
Esempio n. 7
0
        public void Move()
        {
            Point tail = _PointList.FirstOrDefault();

            if (tail != null)
            {
                _PointList.Remove(tail);
                Point head = GetNextPoint();
                _PointList.Add(head);

                tail.Clear();
                head.Drow();
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Point p1 = new Point();

            p1.x   = 1;
            p1.y   = 3;
            p1.sym = '*';
            p1.Drow();

            Point p2 = new Point();

            p2.x   = 5;
            p2.y   = 5;
            p2.sym = '#';
            p2.Drow();

            Console.ReadLine();
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            //Console.SetBufferSize(80, 25);


            FoodCreator foodCreator = new FoodCreator(70, 15, '^');
            Point       food        = foodCreator.CreateFood();

            food.Drow();

            Point p     = new Point(10, 10, '*');
            Snake snake = new Snake(p, 2, Direction.RIGHT);
            Walls walls = new Walls(80, 25);

            walls.Drow();
            snake.Drow();

            while (true)
            {
                if (walls.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Drow();
                }
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.Mandlekey(key.Key);
                }
                Thread.Sleep(100);
                snake.Move();
            }


            //Point p2 = new Point(4,5,'%');

            //Point cp1 = new Point(11, 5, '#');
            //Point cp2 = new Point(-3, 15, '#');
            //Point cp3 = new Point(6, 0, '#');
            //Point cp4 = new Point(2, 10, '#');

            //p2.Drow();
            //List<Point> pList = new List<Point>();
            //pList.Add(p1);
            //pList.Add(p2);

            //List<Point> Cheef = new List<Point>();
            //Cheef.Add(cp1);
            //Cheef.Add(cp2);
            //Cheef.Add(cp3);

            //List<char> sym = new List<char>();
            //sym.Add('*');
            //sym.Add('$');
            //sym.Add('@');
            //char sym1 = sym[0];
            //char sym2 = sym[1];
            //char sym3 = sym[2];

            //List<int> numList = new List<int>();
            //numList.Add(0);
            //numList.Add(1);
            //numList.Add(2);
            //int x = numList[0];
            //int y = numList[1];
            //int z = numList[2];

            //Console.ReadLine();
        }