2 * $Id: firework.c,v 1.10 1997/05/03 18:37:56 tom Exp $
6 #include <term.h> /* for tparm() */
12 static int get_colour(chtype *);
13 static void explode(int row, int col);
14 static void showit(void);
15 static void onsig(int sig);
17 static int my_bg = COLOR_BLACK;
21 char *argv[] GCC_UNUSED)
24 int start,end,row,diff,flag = 0,direction;
27 for (j=SIGHUP;j<=SIGTERM;j++)
28 if (signal(j,SIG_IGN)!=SIG_IGN)
34 #ifdef NCURSES_VERSION
35 if (use_default_colors() == OK)
41 seed = time((time_t *)0);
46 start = rand() % (COLS -3);
47 end = rand() % (COLS - 3);
48 start = (start < 2) ? 2 : start;
49 end = (end < 2) ? 2 : end;
50 direction = (start > end) ? -1 : 1;
51 diff = abs(start-end);
52 } while (diff<2 || diff>=LINES-2);
54 for (row=0;row<diff;row++) {
55 mvprintw(LINES - row,start + (row * direction),
56 (direction < 0) ? "\\" : "/");
67 seed = time((time_t *)0);
69 explode(LINES-row,start+(diff*direction));
76 onsig(int n GCC_UNUSED)
84 void explode(int row, int col)
88 mvprintw(row,col,"-");
91 init_pair(1,get_colour(&bold),my_bg);
92 attrset(COLOR_PAIR(1) | bold);
93 mvprintw(row-1,col-1," - ");
94 mvprintw(row,col-1,"-+-");
95 mvprintw(row+1,col-1," - ");
98 init_pair(1,get_colour(&bold),my_bg);
99 attrset(COLOR_PAIR(1) | bold);
100 mvprintw(row-2,col-2," --- ");
101 mvprintw(row-1,col-2,"-+++-");
102 mvprintw(row, col-2,"-+#+-");
103 mvprintw(row+1,col-2,"-+++-");
104 mvprintw(row+2,col-2," --- ");
107 init_pair(1,get_colour(&bold),my_bg);
108 attrset(COLOR_PAIR(1) | bold);
109 mvprintw(row-2,col-2," +++ ");
110 mvprintw(row-1,col-2,"++#++");
111 mvprintw(row, col-2,"+# #+");
112 mvprintw(row+1,col-2,"++#++");
113 mvprintw(row+2,col-2," +++ ");
116 init_pair(1,get_colour(&bold),my_bg);
117 attrset(COLOR_PAIR(1) | bold);
118 mvprintw(row-2,col-2," # ");
119 mvprintw(row-1,col-2,"## ##");
120 mvprintw(row, col-2,"# #");
121 mvprintw(row+1,col-2,"## ##");
122 mvprintw(row+2,col-2," # ");
125 init_pair(1,get_colour(&bold),my_bg);
126 attrset(COLOR_PAIR(1) | bold);
127 mvprintw(row-2,col-2," # # ");
128 mvprintw(row-1,col-2,"# #");
129 mvprintw(row, col-2," ");
130 mvprintw(row+1,col-2,"# #");
131 mvprintw(row+2,col-2," # # ");
136 int get_colour(chtype *bold)
139 attr = (rand() % 16) + 1;