1 /****************************************************************************
2 * Copyright (c) 2002 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /* $Id: rain.c,v 1.11 2008/07/13 16:08:17 wmcbrine Exp $ */
35 /* rain 11/3/1980 EPS/CITHEP */
37 static int next_j(int j
)
47 chtype color
= COLOR_PAIR(z
);
58 int main(int argc
, char *argv
[])
60 int x
, y
, j
, r
, c
, seed
;
61 static int xpos
[5], ypos
[5];
68 seed
= time((time_t *)0);
77 #if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
78 if (use_default_colors() == OK
)
81 init_pair(1, COLOR_BLUE
, bg
);
82 init_pair(2, COLOR_CYAN
, bg
);
94 for (j
= 5; --j
>= 0;)
96 xpos
[j
] = rand() % c
+ 2;
97 ypos
[j
] = rand() % r
+ 2;
107 mvaddch(ypos
[j
], xpos
[j
], 'o');
110 mvaddch(ypos
[j
], xpos
[j
], 'O');
113 mvaddch(ypos
[j
] - 1, xpos
[j
], '-');
114 mvaddstr(ypos
[j
], xpos
[j
] - 1, "|.|");
115 mvaddch(ypos
[j
] + 1, xpos
[j
], '-');
118 mvaddch(ypos
[j
] - 2, xpos
[j
], '-');
119 mvaddstr(ypos
[j
] - 1, xpos
[j
] - 1, "/ \\");
120 mvaddstr(ypos
[j
], xpos
[j
] - 2, "| O |");
121 mvaddstr(ypos
[j
] + 1, xpos
[j
] - 1, "\\ /");
122 mvaddch(ypos
[j
] + 2, xpos
[j
], '-');
125 mvaddch(ypos
[j
] - 2, xpos
[j
], ' ');
126 mvaddstr(ypos
[j
] - 1, xpos
[j
] - 1, " ");
127 mvaddstr(ypos
[j
], xpos
[j
] - 2, " ");
128 mvaddstr(ypos
[j
] + 1, xpos
[j
] - 1, " ");
129 mvaddch(ypos
[j
] + 2, xpos
[j
], ' ');
142 nodelay(stdscr
, FALSE
);
145 nodelay(stdscr
, TRUE
);