Ejemplo n.º 1
0
        public JocSnake()
        {
            cap      = new Point(0, 0);
            caps     = new List <Point>();
            direccio = DireccioSnake.Sud;
            pomes    = new List <Point>();
            //distribuir les pomes
            Random r = new Random();

            for (int i = 0; i < NPOMES; i++)
            {
                var x = r.Next(0, WIDTH - 1);
                var y = r.Next(0, HEIGHT - 1);
                while (x == 0 && y == 0)
                {
                    x = r.Next(0, WIDTH - 1);
                    y = r.Next(0, HEIGHT - 1);
                }

                pomes.Add(new Point(x, y));
            }
        }
Ejemplo n.º 2
0
        public JocRobot(IintercanviEstat finestra)
        {
            this.finestra = finestra;
            cap           = new Point(0, 0);
            caps          = new List <Point>();
            direccio      = DireccioSnake.Sud;
            pomes         = new List <Point>();
            //distribuir les pomes
            Random r = new Random();

            for (int i = 0; i < NPOMES; i++)
            {
                var x = r.Next(0, WIDTH - 1);
                var y = r.Next(0, HEIGHT - 1);
                while (x == 0 && y == 0)
                {
                    x = r.Next(0, WIDTH - 1);
                    y = r.Next(0, HEIGHT - 1);
                }

                pomes.Add(new Point(x, y));
            }
        }