static void UpdateTitle() { if (titleScrollTimer.DoThing()) { titleOffset += 1; if (titleOffset > title.GetLength(0) - 10) { titleOffset = 0; } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 20; j++) { board[j, i] = title[i + titleOffset, j]; } } while (Console.KeyAvailable) { char ch = Console.ReadKey(true).KeyChar; switch (ch) { case 'a': case 'd': case 's': UpdateBackground(); board[board.GetLength(0) - 2, bat.Col] = new Pixel(255, 255, 255); state = State.Playing; break; } } }
static void UpdateFallingStuff() { if (dropTimer.DoThing()) { for (int i = 0; i < Falling.Count; i++) { board[Falling[i].Row, Falling[i].Col] = background[Falling[i].Row, Falling[i].Col]; Falling[i].Row++; } CheckLaserCollisions(); for (int i = Falling.Count - 1; i >= 0; i--) { if (Falling[i].Row == board.GetLength(0)) { if (cats[Falling[i].Col] == 1) { cats[Falling[i].Col] = 0; } Falling.RemoveAt(i); } } foreach (Coord c in Falling) { board[c.Row, c.Col] = c.Colour; } } if (spawnTimer.DoThing()) { Coord faller = new Coord(); faller.Col = rng.Next(0, board.GetLength(1)); faller.Row = 0; int i = rng.Next(9); while (Math.Abs(i - faller.Col) < 2) { i = rng.Next(9); } faller.Colour = (Pixel)brightRainbow[i]; Falling.Add(faller); board[faller.Row, faller.Col] = faller.Colour; } }
static void UpdateCats() { if (catTimer.DoThing()) { for (int i = 0; i < cats.Length; i++) { if (cats[i] != 0) { int move = rng.Next(3); switch (move) { case 1: if (i > 0 && cats[i - 1] == 0) { cats[i - 1] = 1; cats[i] = 0; } break; case 2: if (i != 9 && cats[i + 1] == 0) { cats[i + 1] = 1; cats[i] = 0; } break; } } } } for (int i = 0; i < cats.Length; i++) { if (cats[i] == 1) { board[board.GetLength(0) - 1, i] = new Pixel(0, 255, 0); } else { board[board.GetLength(0) - 1, i] = new Pixel(0, 0, 0); } } }