private static bool InitializeNCurses(ref IntPtr screen, short[] colorMap, Byte width, Byte height) { screen = NCurses.InitScreen(); if (NCurses.HasColors() == false) { Console.WriteLine("Your terminal doesn't support colored output."); NCurses.EndWin(); return(false); } if ((NCurses.Columns < width - 1) || (NCurses.Lines < height - 1)) { Console.WriteLine($"Your terminal must be {width}x{height}. You have {NCurses.Columns}x{NCurses.Lines}"); NCurses.EndWin(); return(false); } NCurses.NoDelay(screen, true); NCurses.NoEcho(); NCurses.AttributeSet(CursesAttribute.NORMAL); NCurses.StartColor(); NCurses.InitPair(colorMap[0], CursesColor.BLACK, CursesColor.BLACK); NCurses.InitPair(colorMap[1], CursesColor.WHITE, CursesColor.WHITE); return(true); }
private static void Fireworks() { NCurses.NoDelay(Screen, true); NCurses.NoEcho(); if (NCurses.HasColors()) { NCurses.StartColor(); for (short i = 1; i < 8; i++) { NCurses.InitPair(i, color_table[i], CursesColor.BLACK); } } int flag = 0; while (NCurses.GetChar() == -1) { int start, end, row, diff, direction; do { start = rng.Next(NCurses.Columns - 3); end = rng.Next(NCurses.Columns - 3); start = (start < 2) ? 2 : start; end = (end < 2) ? 2 : end; direction = (start > end) ? -1 : 1; diff = Math.Abs(start - end); } while (diff < 2 || diff >= NCurses.Lines - 2); NCurses.AttributeSet(CursesAttribute.NORMAL); for (row = 1; row < diff; ++row) { NCurses.MoveAddString(NCurses.Lines - row, row * direction + start, (direction < 0) ? "\\" : "/"); if (flag++ > 0) { MyRefresh(); NCurses.Erase(); flag = 0; } } if (flag++ > 0) { MyRefresh(); flag = 0; } Explode(NCurses.Lines - row, diff * direction + start); NCurses.Erase(); MyRefresh(); } }