Ejemplo n.º 1
0
        private static Point GetRandomPoint(Arena arena, Snake otherSnake)
        {
            Point p = new Point()
            {
                X = rnd.Next(Arena.WindowWidth),
                Y = rnd.Next(Arena.WindowHeight)
            };

            while (arena.HasBlockAt(p))
            {
                p = new Point()
                {
                    X = rnd.Next(Arena.WindowWidth),
                    Y = rnd.Next(Arena.WindowHeight)
                };
            }

            return p;
        }
Ejemplo n.º 2
0
        private static Point GenerateFoodPoint(Arena arena, Snake[] snakes)
        {
            Point p = new Point() { X = rnd.Next(Arena.WindowWidth), Y = rnd.Next(Arena.WindowHeight) };

            while (arena.HasBlockAt(p) ||
                   snakes.Any(sn => sn.BodyCollides(p)))
            {
                p = new Point() { X = rnd.Next(Arena.WindowWidth), Y = rnd.Next(Arena.WindowHeight) };
            }

            return p;
        }