static void InitializeRockRows() { for (int i = 0; i < Console.WindowHeight - 1; i++) { rocks[i] = new RockRow(); for (int j = 0; j < 5; j++) { rocks[i].row[j] = new Rock(); } } }
static void GenerateFirstRow() { Random generator = new Random(); int numberOfRocks = generator.Next(1, 6); rocks[0] = new RockRow(numberOfRocks); for (int i = 0; i < numberOfRocks; i++) { int column = generator.Next(0, Console.WindowWidth - 3); int density = generator.Next(1, 4); int colorNum = generator.Next(1, 8); int symbolNum = generator.Next(1, 8); char symbol = '0'; ConsoleColor color = ConsoleColor.Black; switch (colorNum) { case 1: color = ConsoleColor.Blue; break; case 2: color = ConsoleColor.DarkGreen; break; case 3: color = ConsoleColor.DarkGray; break; case 4: color = ConsoleColor.DarkRed; break; case 5: color = ConsoleColor.DarkCyan; break; case 6: color = ConsoleColor.DarkYellow; break; case 7: color = ConsoleColor.DarkMagenta; break; default: Console.WriteLine("Something's wrong..."); break; } switch (symbolNum) { case 1: symbol = '^'; break; case 2: symbol = '@'; break; case 3: symbol = '*'; break; case 4: symbol = '&'; break; case 5: symbol = '+'; break; case 6: symbol = '%'; break; case 7: symbol = '$'; break; default: Console.WriteLine("something's wrong"); break; } rocks[0].row[i] = new Rock(column, density, color, symbol); } }
static void MoveRocks() { for (int i = Console.WindowHeight - 2; i > 0; i--) { int newLength = rocks[i - 1].rowLength; rocks[i] = new RockRow(newLength); for (int j = 0; j < newLength; j++) { rocks[i].row[j] = new Rock(rocks[i - 1].row[j].column, rocks[i - 1].row[j].density, rocks[i - 1].row[j].color, rocks[i - 1].row[j].symbol); } } }