Exemplo n.º 1
0
 /* Prints some generated object */
 static void PrintObject(ObjectCordinates obj, char sym, ConsoleColor col)
 {
     Console.SetCursorPosition(obj.col, obj.row);
     Console.ForegroundColor = col;
     Console.BackgroundColor = ConsoleColor.Black;
     Console.Write(sym);
     Console.ResetColor();
 }
Exemplo n.º 2
0
        /* Generate random position of some object */
        static ObjectCordinates GenerateObject(string map, List<int[]> Snake)
        {
            ObjectCordinates obj;

            /* Generates a new object if coordinates are the same like these of the Snake or the wall */
            do
            {
                obj = new ObjectCordinates(Generator.Next(0, Console.WindowWidth - 2), Generator.Next(1, Console.WindowHeight));
                if (obj.col % 2 == 0) obj.col += 1;
            }
            while (Snake.Any(x => x.SequenceEqual(new int[] { obj.col, obj.row })) || OverWallCheck(map, new int[] { obj.col, obj.row }));
            return obj;
        }