1 /* $Id: firework.c,v 1.25 2008/07/13 16:08:17 wmcbrine Exp $ */
15 void explode(int, int);
19 COLOR_RED
, COLOR_BLUE
, COLOR_GREEN
, COLOR_CYAN
,
20 COLOR_RED
, COLOR_MAGENTA
, COLOR_YELLOW
, COLOR_WHITE
23 int main(int argc
, char **argv
)
25 int i
, start
, end
, row
, diff
, flag
, direction
, seed
;
32 nodelay(stdscr
, TRUE
);
38 for (i
= 0; i
< 8; i
++)
39 init_pair(i
, color_table
[i
], COLOR_BLACK
);
41 seed
= time((time_t *)0);
45 while (getch() == ERR
) /* loop until a key is hit */
48 start
= rand() % (COLS
- 3);
49 end
= rand() % (COLS
- 3);
50 start
= (start
< 2) ? 2 : start
;
51 end
= (end
< 2) ? 2 : end
;
52 direction
= (start
> end
) ? -1 : 1;
53 diff
= abs(start
- end
);
55 } while (diff
< 2 || diff
>= LINES
- 2);
59 for (row
= 0; row
< diff
; row
++)
61 mvaddstr(LINES
- row
, row
* direction
+ start
,
62 (direction
< 0) ? "\\" : "/");
78 explode(LINES
- row
, diff
* direction
+ start
);
88 void explode(int row
, int col
)
91 mvaddstr(row
, col
, "-");
97 mvaddstr(row
- 1, col
, " - ");
98 mvaddstr(row
, col
, "-+-");
99 mvaddstr(row
+ 1, col
, " - ");
105 mvaddstr(row
- 2, col
, " --- ");
106 mvaddstr(row
- 1, col
, "-+++-");
107 mvaddstr(row
, col
, "-+#+-");
108 mvaddstr(row
+ 1, col
, "-+++-");
109 mvaddstr(row
+ 2, col
, " --- ");
113 mvaddstr(row
- 2, col
, " +++ ");
114 mvaddstr(row
- 1, col
, "++#++");
115 mvaddstr(row
, col
, "+# #+");
116 mvaddstr(row
+ 1, col
, "++#++");
117 mvaddstr(row
+ 2, col
, " +++ ");
121 mvaddstr(row
- 2, col
, " # ");
122 mvaddstr(row
- 1, col
, "## ##");
123 mvaddstr(row
, col
, "# #");
124 mvaddstr(row
+ 1, col
, "## ##");
125 mvaddstr(row
+ 2, col
, " # ");
129 mvaddstr(row
- 2, col
, " # # ");
130 mvaddstr(row
- 1, col
, "# #");
131 mvaddstr(row
, col
, " ");
132 mvaddstr(row
+ 1, col
, "# #");
133 mvaddstr(row
+ 2, col
, " # # ");
140 move(LINES
- 1, COLS
- 1);
146 chtype bold
= (rand() % 2) ? A_BOLD
: A_NORMAL
;
147 attrset(COLOR_PAIR(rand() % 8) | bold
);