2 * $Id: rain.c,v 1.20 2002/06/29 23:32:18 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 setlocale(LC_ALL, "");
40 for (j = SIGHUP; j <= SIGTERM; j++)
41 if (signal(j, SIG_IGN) != SIG_IGN)
48 #if HAVE_USE_DEFAULT_COLORS
49 if (use_default_colors() == OK)
52 init_pair(1, COLOR_BLUE, bg);
53 init_pair(2, COLOR_CYAN, bg);
60 r = (float) (LINES - 4);
61 c = (float) (COLS - 4);
62 for (j = 5; --j >= 0;) {
63 xpos[j] = (int) (c * ranf()) + 2;
64 ypos[j] = (int) (r * ranf()) + 2;
68 x = (int) (c * ranf()) + 2;
69 y = (int) (r * ranf()) + 2;
73 mvaddch(ypos[j], xpos[j], 'o');
76 mvaddch(ypos[j], xpos[j], 'O');
79 mvaddch(ypos[j] - 1, xpos[j], '-');
80 mvaddstr(ypos[j], xpos[j] - 1, "|.|");
81 mvaddch(ypos[j] + 1, xpos[j], '-');
84 mvaddch(ypos[j] - 2, xpos[j], '-');
85 mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
86 mvaddstr(ypos[j], xpos[j] - 2, "| O |");
87 mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
88 mvaddch(ypos[j] + 2, xpos[j], '-');
91 mvaddch(ypos[j] - 2, xpos[j], ' ');
92 mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
93 mvaddstr(ypos[j], xpos[j] - 2, " ");
94 mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
95 mvaddch(ypos[j] + 2, xpos[j], ' ');
105 ExitProgram(EXIT_SUCCESS);
107 nodelay(stdscr, FALSE);
110 nodelay(stdscr, TRUE);
114 r = (float) (LINES - 4);
115 c = (float) (COLS - 4);
124 onsig(int n GCC_UNUSED)
128 ExitProgram(EXIT_FAILURE);
134 long r = (rand() & 077777);
135 return ((float) r / 32768.);