Exemplo n.º 1
0
        private void Run()
        {
            Initialize();
            while (true)
            {
                Stdscr.Erase();
                for (int i = 0; i < lines.Length; ++i)
                {
                    if (offsets[i] <= 0)
                    {
                        lines[i]   = null;
                        offsets[i] = 0;
                    }
                    if (lines[i] == null)
                    {
                        lines[i]   = TEXT_LINES[rng.Next(TEXT_LINES.Length)];
                        offsets[i] = colcount + lines[i].Length;
                    }
                    int    of  = colcount - offsets[i];
                    string str = lines[i];
                    if (of < 0)
                    {
                        int ln = Math.Min(str.Length + of, colcount);
                        str = str.Substring(-of, ln);
                        of  = 0;
                    }
                    else
                    {
                        int ln = Math.Min(Math.Min(offsets[i], str.Length), colcount);
                        str = str.Substring(0, ln);
                    }
                    Stdscr.Add(i, of, str);
                    offsets[i]--;
                }
                Stdscr.Refresh();

                switch (Stdscr.GetChar())
                {
                case 'q':
                case 'Q':
                    Curses.CursorVisibility = 1;
                    return;

                default: break;
                }
                Curses.NapMs(100);
            }
        }
Exemplo n.º 2
0
 private static void MyRefresh()
 {
     Curses.NapMs(DELAYSIZE);
     Stdscr.Move(Curses.Lines - 1, Curses.Cols - 1);
     Stdscr.Refresh();
 }
Exemplo n.º 3
0
        private static void Main2()
        {
            rng = new Random();
            if (Curses.HasColors)
            {
                Curses.StartColor();
                short bg = Colors.BLACK;
                try
                {
                    Curses.UseDefaultColors();
                    bg = -1;
                }
                catch (CursesException) { }
                Curses.InitPair(1, Colors.BLUE, bg);
                Curses.InitPair(2, Colors.CYAN, bg);
            }
            Curses.Newlines         = true;
            Curses.Echo             = false;
            Curses.CursorVisibility = 0;
            Stdscr.ReadTimeout      = 0;
            Stdscr.Keypad           = true;

            int r = Curses.Lines - 4, c = Curses.Cols - 4;

            int[] xpos = new int[5];
            int[] ypos = new int[5];
            for (int j = 0; j < 5; ++j)
            {
                xpos[j] = rng.Next(c) + 2;
                ypos[j] = rng.Next(r) + 2;
            }

            for (int j = 0; ;)
            {
                int x = rng.Next(c) + 2;
                int y = rng.Next(r) + 2;

                Stdscr.Add(y, x, '.');

                Stdscr.Add(ypos[j], xpos[j], 'o');

                j = NextJ(j);
                Stdscr.Add(ypos[j], xpos[j], 'O');

                j = NextJ(j);
                Stdscr.Add(ypos[j] - 1, xpos[j], '-');
                Stdscr.Add(ypos[j], xpos[j] - 1, "|.|");
                Stdscr.Add(ypos[j] + 1, xpos[j], '-');

                j = NextJ(j);
                Stdscr.Add(ypos[j] - 2, xpos[j], '-');
                Stdscr.Add(ypos[j] - 1, xpos[j] - 1, "/ \\");
                Stdscr.Add(ypos[j], xpos[j] - 2, "| O |");
                Stdscr.Add(ypos[j] + 1, xpos[j] - 1, "\\ /");
                Stdscr.Add(ypos[j] + 2, xpos[j], '-');

                j = NextJ(j);
                Stdscr.Add(ypos[j] - 2, xpos[j], ' ');
                Stdscr.Add(ypos[j] - 1, xpos[j] - 1, "   ");
                Stdscr.Add(ypos[j], xpos[j] - 2, "     ");
                Stdscr.Add(ypos[j] + 1, xpos[j] - 1, "   ");
                Stdscr.Add(ypos[j] + 2, xpos[j], ' ');

                xpos[j] = x;
                ypos[j] = y;

                switch (Stdscr.GetChar())
                {
                case 'q':
                case 'Q':
                    Curses.CursorVisibility = 1;
                    return;

                case 's':
                    Stdscr.Blocking = true;
                    break;

                case ' ':
                    Stdscr.Blocking = false;
                    break;

                default: break;
                }
                Curses.NapMs(50);
            }
        }