/// <summary> /// Shows the current screen state /// TODO: make the draw functions return the differences, and add an enum so there can be different ways to show /// </summary> /// <param name="compareWithLast">Should it compare to the last screen to improve performance</param> public void Show(bool compareWithLast = true) { // If the the flag was left on if (compareWithLast) { // Gets the differences from the current and last map state List <Tuple <int, int> > differenceList = ConsoleBlockMap.Differences(_Map, _LastMap); int index; // Iterates through each difference foreach (Tuple <int, int> difference in differenceList) { for (index = difference.Item1; index < difference.Item2; index++) { // And updates only the different blocks from the screen Console.SetCursorPosition(index % _Map.Width, index / _Map.Width); _Map[index].Show(); } } } // If it was NOT else { // Then get yourself ready Console.SetCursorPosition(0, 0); // For the lag _Map.Show(); } // Updates the last map state _LastMap.CopyFrom(_Map); }
/// <summary> /// Clears the screen with a given background /// </summary> /// <param name="background">Background</param> public void Clear(ConsoleBlockMap background) { _Map.CopyFrom(background); }