2 * $Id: firework.c,v 1.20 2002/03/23 21:41:42 tom Exp $
8 static int my_bg = COLOR_BLACK;
18 onsig(int n GCC_UNUSED)
21 ExitProgram(EXIT_FAILURE);
29 if ((ch = getch()) != ERR) {
31 if (ch == KEY_RESIZE) {
37 ExitProgram(EXIT_SUCCESS);
38 } else if (ch == 's') {
39 nodelay(stdscr, FALSE);
40 } else if (ch == ' ') {
41 nodelay(stdscr, TRUE);
48 get_colour(chtype * bold)
51 attr = (rand() % 16) + 1;
63 explode(int row, int col)
67 mvprintw(row, col, "-");
70 init_pair(1, get_colour(&bold), my_bg);
71 attrset(COLOR_PAIR(1) | bold);
72 mvprintw(row - 1, col - 1, " - ");
73 mvprintw(row + 0, col - 1, "-+-");
74 mvprintw(row + 1, col - 1, " - ");
77 init_pair(1, get_colour(&bold), my_bg);
78 attrset(COLOR_PAIR(1) | bold);
79 mvprintw(row - 2, col - 2, " --- ");
80 mvprintw(row - 1, col - 2, "-+++-");
81 mvprintw(row + 0, col - 2, "-+#+-");
82 mvprintw(row + 1, col - 2, "-+++-");
83 mvprintw(row + 2, col - 2, " --- ");
86 init_pair(1, get_colour(&bold), my_bg);
87 attrset(COLOR_PAIR(1) | bold);
88 mvprintw(row - 2, col - 2, " +++ ");
89 mvprintw(row - 1, col - 2, "++#++");
90 mvprintw(row + 0, col - 2, "+# #+");
91 mvprintw(row + 1, col - 2, "++#++");
92 mvprintw(row + 2, col - 2, " +++ ");
95 init_pair(1, get_colour(&bold), my_bg);
96 attrset(COLOR_PAIR(1) | bold);
97 mvprintw(row - 2, col - 2, " # ");
98 mvprintw(row - 1, col - 2, "## ##");
99 mvprintw(row + 0, col - 2, "# #");
100 mvprintw(row + 1, col - 2, "## ##");
101 mvprintw(row + 2, col - 2, " # ");
104 init_pair(1, get_colour(&bold), my_bg);
105 attrset(COLOR_PAIR(1) | bold);
106 mvprintw(row - 2, col - 2, " # # ");
107 mvprintw(row - 1, col - 2, "# #");
108 mvprintw(row + 0, col - 2, " ");
109 mvprintw(row + 1, col - 2, "# #");
110 mvprintw(row + 2, col - 2, " # # ");
117 char *argv[]GCC_UNUSED)
120 int start, end, row, diff, flag = 0, direction;
123 for (j = SIGHUP; j <= SIGTERM; j++)
124 if (signal(j, SIG_IGN) != SIG_IGN)
130 keypad(stdscr, TRUE);
131 nodelay(stdscr, TRUE);
135 #if HAVE_USE_DEFAULT_COLORS
136 if (use_default_colors() == OK)
142 seed = time((time_t *) 0);
146 start = rand() % (COLS - 3);
147 end = rand() % (COLS - 3);
148 start = (start < 2) ? 2 : start;
149 end = (end < 2) ? 2 : end;
150 direction = (start > end) ? -1 : 1;
151 diff = abs(start - end);
152 } while (diff < 2 || diff >= LINES - 2);
154 for (row = 0; row < diff; row++) {
155 mvprintw(LINES - row, start + (row * direction),
156 (direction < 0) ? "\\" : "/");
167 seed = time((time_t *) 0);
169 explode(LINES - row, start + (diff * direction));