Ejemplo n.º 1
0
        public static void MoveSnakeThread()
        {
            while (true)
            {
                Snake.draw();
                Food.draw();
                //  food1.draw1();
                Wall.draw();


                wall.Level();
                food.Process(wall);
                z++;
                z %= 60;
                if (z == 59 && bigfoodexists == false)
                {
                    BigFood.draw();
                    bigfoodexists = true;
                }



                switch (direction)
                {
                case 1:
                    snake.Move(0, -1);

                    break;

                case 2:
                    snake.Move(0, 1);

                    break;

                case 3:
                    snake.Move(1, 0);

                    break;

                case 4:
                    snake.Move(-1, 0);

                    break;
                }



                wall.Scoremenu();
                if (Snake.body[0].x < 0)
                {
                    Snake.body[0].x = 60;
                }
                if (Snake.body[0].x > 60)
                {
                    Snake.body[0].x = 0;
                }
                if (Snake.body[0].y < 0)
                {
                    Snake.body[0].y = 30;
                }
                if (Snake.body[0].y > 30)
                {
                    Snake.body[0].y = 0;
                }
                Console.SetCursorPosition(0, 33);
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine("Your Score: " + score);


                if (snake.Eat())
                {
                    score += 1;
                    Console.SetCursorPosition(0, 33);
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("Your Score: " + score);
                }
                if (snake.Eat1())
                {
                    score += 3;
                    Console.SetCursorPosition(0, 33);
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("Your Score: " + score);
                    bigfoodexists = false;
                }
                if (score > 7)
                {
                    Console.Clear();
                    snake.NewLevel();
                    Wall.level++;
                    if (Wall.level > 2)
                    {
                        Wall.level = 1;
                        score      = 0;
                    }
                }



                if (bigfood.IsontheSnake() == false || bigfood.Isonthewall() == false)
                {
                    bigfood.setrandompos();
                }
                if (snake.D1() == false || snake.D2() == false)
                {
                    realgameover = true;
                    gameover     = true;
                    Gameover();
                }
                if (food.Isonthefood() == false)
                {
                    food.setrandompos();
                }
                if (bigfood.Isonthefood() == false)
                {
                    bigfood.setrandompos();
                }

                Thread.Sleep(speed);
            }
        }