Exemplo n.º 1
0
 public bool IsHit(point p)
 {
     return(p.x == this.x && p.y == this.y);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.Write("Напиши свое имя: ");
            string name = Console.ReadLine();

            Console.SetWindowSize(80, 27);

            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.draw();

            Params settings = new Params();
            Sounds sound    = new Sounds(settings.GetResourceFolder());

            sound.Play();



            Sounds sound1 = new Sounds(settings.GetResourceFolder());

            while (true)
            {
                if (walls.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }
                if (snake.Eat(food))
                {
                    Score ScoreGame = new Score();
                    ScoreGame.ScoreInGame(snake.score);
                    food = foodCreator.CreateFood();
                    food.draw();
                    sound1.PlayEat();
                }
                else
                {
                    snake.Move();
                }

                Thread.Sleep(100);
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
            }
            sound.Stop();
            GameOverSnake GameOver = new GameOverSnake();

            GameOver.WriteGameOver(name, snake.score);
            Console.ReadLine();
        }
Exemplo n.º 3
0
 public point(point p)
 {
     x   = p.x;
     y   = p.y;
     sym = p.sym;
 }