Esempio n. 1
0
        public void Play()
        {
            SnekePartMove   headPart        = new SnekePartMove(0xFF1e8a19, 0, 200, _graphics);
            SimpleSnakePart simpleSnakePart = new SimpleSnakePart(0xFF325230, 400, 200, _graphics);

            snakeParts.Add(headPart);

            while (headPart.IsAlive())
            {
                _canvas.Render(_graphics);

                SnakeHelper.Render(_graphics, snakeParts);
                SnakeHelper.Move(snakeParts);

                simpleSnakePart.Render(_graphics);

                if (SnakeHelper.ContactWithOneself(snakeParts))
                {
                    break;
                }

                if (simpleSnakePart.Contact(simpleSnakePart, headPart))
                {
                    snakeParts.Add(simpleSnakePart);
                    simpleSnakePart = simpleSnakePart.CriateSimplePart(snakeParts, _graphics);
                    points++;
                }

                _graphics.FlipPages();

                Thread.Sleep(100);
            }
        }
Esempio n. 2
0
        public static void Move(CustomList.List <SnekePartMove> snake)
        {
            SnekePartMove head = snake[0];

            for (int i = snake.Count - 1; i > 0; i--)
            {
                snake[i].X = snake[i - 1].X;
                snake[i].Y = snake[i - 1].Y;
            }
            head.Update();
        }
Esempio n. 3
0
 public bool Contact(SimpleSnakePart simplePart, SnekePartMove movePart)
 {
     if (simplePart.X == movePart.X && simplePart.Y == movePart.Y)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }