2 * $Id: rain.c,v 1.19 2002/04/06 20:45:22 tom Exp $
6 /* rain 11/3/1980 EPS/CITHEP */
8 static float ranf(void);
9 static void onsig(int sig);
19 int z = (int) (3 * ranf());
20 chtype color = COLOR_PAIR(z);
31 char *argv[]GCC_UNUSED)
34 static int xpos[5], ypos[5];
38 for (j = SIGHUP; j <= SIGTERM; j++)
39 if (signal(j, SIG_IGN) != SIG_IGN)
46 #if HAVE_USE_DEFAULT_COLORS
47 if (use_default_colors() == OK)
50 init_pair(1, COLOR_BLUE, bg);
51 init_pair(2, COLOR_CYAN, bg);
58 r = (float) (LINES - 4);
59 c = (float) (COLS - 4);
60 for (j = 5; --j >= 0;) {
61 xpos[j] = (int) (c * ranf()) + 2;
62 ypos[j] = (int) (r * ranf()) + 2;
66 x = (int) (c * ranf()) + 2;
67 y = (int) (r * ranf()) + 2;
71 mvaddch(ypos[j], xpos[j], 'o');
74 mvaddch(ypos[j], xpos[j], 'O');
77 mvaddch(ypos[j] - 1, xpos[j], '-');
78 mvaddstr(ypos[j], xpos[j] - 1, "|.|");
79 mvaddch(ypos[j] + 1, xpos[j], '-');
82 mvaddch(ypos[j] - 2, xpos[j], '-');
83 mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
84 mvaddstr(ypos[j], xpos[j] - 2, "| O |");
85 mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
86 mvaddch(ypos[j] + 2, xpos[j], '-');
89 mvaddch(ypos[j] - 2, xpos[j], ' ');
90 mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
91 mvaddstr(ypos[j], xpos[j] - 2, " ");
92 mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
93 mvaddch(ypos[j] + 2, xpos[j], ' ');
103 ExitProgram(EXIT_SUCCESS);
105 nodelay(stdscr, FALSE);
108 nodelay(stdscr, TRUE);
112 r = (float) (LINES - 4);
113 c = (float) (COLS - 4);
122 onsig(int n GCC_UNUSED)
126 ExitProgram(EXIT_FAILURE);
132 long r = (rand() & 077777);
133 return ((float) r / 32768.);