1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
|
/* -*- Mode: C; tab-width: 4 -*- */
/* pyro --- fireworks */
#if !defined( lint ) && !defined( SABER )
static const char sccsid[] = "@(#)pyro.c 4.07 97/11/24 xlockmore";
#endif
/*-
* Copyright (c) 1991 by Patrick J. Naughton.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation.
*
* This file is provided AS IS with no warranties of any kind. The author
* shall have no liability with respect to the infringement of copyrights,
* trade secrets or any patents by this file or any part thereof. In no
* event will the author be liable for any lost revenue or profits or
* other special, indirect and consequential damages.
*
* Revision History:
* 15-May-97: jwz@netscape.com: turned into a standalone program.
* 05-Sep-96: Added 3d support Henrik Theiling <theiling@coli.uni-sb.de>
* 16-Mar-91: Written, received from David Brooks <brooks@osf.org>
*/
/*-
* The physics of the rockets is a little bogus, but it looks OK. Each is
* given an initial velocity impetus. They decelerate slightly (gravity
* overcomes the rocket's impulse) and explode as the rocket's main fuse
* gives out (we could add a ballistic stage, maybe). The individual
* stars fan out from the rocket, and they decelerate less quickly.
* That's called bouyancy, but really it's again a visual preference.
*/
#ifdef STANDALONE
#define PROGCLASS "Pyro"
#define HACK_INIT init_pyro
#define HACK_DRAW draw_pyro
#define pyro_opts xlockmore_opts
#define DEFAULTS "*delay: 15000 \n" \
"*count: 100 \n" \
"*size: -3 \n" \
"*ncolors: 200 \n" \
"*use3d: False \n" \
"*delta3d: 1.5 \n" \
"*right3d: red \n" \
"*left3d: blue \n" \
"*both3d: magenta \n" \
"*none3d: black \n"
#include "xlockmore.h" /* in xscreensaver distribution */
#else /* STANDALONE */
#include "xlock.h" /* in xlockmore distribution */
#endif /* STANDALONE */
ModeSpecOpt pyro_opts =
{0, NULL, 0, NULL, NULL};
#ifdef USE_MODULES
ModStruct pyro_description =
{"pyro", "init_pyro", "draw_pyro", "release_pyro",
"refresh_pyro", "init_pyro", NULL, &pyro_opts,
15000, 100, 1, -3, 64, 1.0, "",
"Shows fireworks", 0, NULL};
#endif
#define ORANGE (MI_NPIXELS(mi) / 16)
#define MINROCKETS 1
#define MINSIZE 1
#define SILENT 0
#define REDGLARE 1
#define BURSTINGINAIR 2
#define CLOUD 0
#define DOUBLECLOUD 1
#define COLORCLOUD 2
/* Clearly other types and other fascinating visual effects could be added... */
/* P_xxx parameters represent the reciprocal of the probability... */
#define P_IGNITE 5000 /* ...of ignition per cycle */
#define P_DOUBLECLOUD 10 /* ...of an ignition being double */
#define P_COLORCLOUD 5 /* ...of an ignition being full color */
#define P_MULTI 75 /* ...of an ignition being several @ once */
#define P_FUSILLADE 250 /* ...of an ignition starting a fusillade */
#define ROCKETW 2 /* Dimensions of rocket */
#define ROCKETH 4
#define XVELFACTOR 0.0025 /* Max horizontal velocity / screen width */
#define ZVELFACTOR 0.0025
#define MINZVAL 250 /* absolute minimum of z values */
#define MINZVALSTART 300 /* range where they start */
#define MAXZVALSTART 1000
#define SCREENZ 400
/* the z-component still gets too small sometimes */
#define GETZDIFFAUX(z) (MI_DELTA3D(mi)*20.0*(1.0-(SCREENZ)/(z)))
#define GETZDIFF(z) ((z)<MINZVAL?GETZDIFFAUX(MINZVAL):GETZDIFFAUX(z))
#define MINYVELFACTOR 0.016 /* Min vertical velocity / screen height */
#define MAXYVELFACTOR 0.018
#define GRAVFACTOR 0.0002 /* delta v / screen height */
#define MINFUSE 50 /* range of fuse lengths for rocket */
#define MAXFUSE 100
#define FUSILFACTOR 10 /* Generate fusillade by reducing P_IGNITE */
#define FUSILLEN 100 /* Length of fusillade, in ignitions */
#define SVELFACTOR 0.1 /* Max star velocity / yvel */
#define BOUYANCY 0.2 /* Reduction in grav deceleration for stars */
#define MAXSTARS 150 /* Number of stars issued from a shell */
#define MINSTARS 50
#define MINSFUSE 50 /* Range of fuse lengths for stars */
#define MAXSFUSE 100
#define INTRAND(min,max) (NRAND((max+1)-(min))+(min))
#define FLOATRAND(min,max) ((min)+((double) LRAND()/((double) MAXRAND))*((max)-(min)))
#define INCZ(val,add) if((val)+(add)>MINZVAL) val+=(add)
#define ADDZ(val,add) (((val)+(add)>MINZVAL)?(val)+(add):(val))
#define TWOPI (2.0*M_PI)
typedef struct {
unsigned long color;
float sx, sy, sz; /* Distance from notional center */
float sxvel, syvel, szvel; /* Relative to notional center */
} star;
typedef struct {
int state;
int shelltype;
int fuse;
float xvel, yvel, zvel;
float x, y, z;
unsigned long color[2];
int nstars;
XRectangle Xpoints[2][MAXSTARS];
XRectangle Xpointsleft[2][MAXSTARS];
star stars[MAXSTARS];
} rocket;
typedef struct {
int p_ignite;
unsigned long rockpixel;
int nflying, nrockets;
int fusilcount;
int width, height;
int lmargin, rmargin;
int star_size;
float minvelx, maxvelx;
float minvely, maxvely;
float minvelz, maxvelz;
float maxsvel;
float rockdecel, stardecel;
rocket *rockq;
} pyrostruct;
static void shootup(ModeInfo * mi, pyrostruct * pp, rocket * rp);
static void burst(ModeInfo * mi, pyrostruct * pp, rocket * rp);
static pyrostruct *pyros = NULL;
static int orig_p_ignite;
static int just_started = True; /* Greet the user right away */
static void
ignite(ModeInfo * mi, pyrostruct * pp)
{
rocket *rp;
int multi, shelltype, nstars, fuse, pix;
unsigned long color[2];
float xvel, yvel, x, zvel = 0.0, z = 0.0;
x = NRAND(pp->width);
xvel = FLOATRAND(-pp->maxvelx, pp->maxvelx);
/* All this to stop too many rockets going offscreen: */
if ((x < pp->lmargin && xvel < 0.0) || (x > pp->rmargin && xvel > 0.0))
xvel = -xvel;
yvel = FLOATRAND(pp->minvely, pp->maxvely);
if (MI_WIN_IS_USE3D(mi)) {
z = FLOATRAND(MINZVALSTART, MAXZVALSTART);
zvel = FLOATRAND(pp->minvelz, pp->maxvelz);
}
fuse = INTRAND(MINFUSE, MAXFUSE);
nstars = INTRAND(MINSTARS, MAXSTARS);
if (MI_NPIXELS(mi) > 2) {
pix = NRAND(MI_NPIXELS(mi));
color[0] = MI_PIXEL(mi, pix);
color[1] = MI_PIXEL(mi,
((pix + (MI_NPIXELS(mi) / 2)) % MI_NPIXELS(mi)));
} else {
color[0] = color[1] = MI_WHITE_PIXEL(mi);
}
multi = 1;
if (NRAND(P_DOUBLECLOUD) == 0)
shelltype = DOUBLECLOUD;
else {
shelltype = CLOUD;
if (NRAND(P_MULTI) == 0)
multi = INTRAND(5, 15);
}
if (NRAND(P_COLORCLOUD) == 0)
shelltype |= COLORCLOUD;
rp = pp->rockq;
while (multi--) {
if (pp->nflying >= pp->nrockets)
return;
while (rp->state != SILENT)
rp++;
pp->nflying++;
rp->shelltype = shelltype;
rp->state = REDGLARE;
rp->color[0] = color[0];
rp->color[1] = color[1];
rp->xvel = xvel;
rp->yvel = FLOATRAND(yvel * 0.97, yvel * 1.03);
rp->fuse = INTRAND((fuse * 90) / 100, (fuse * 110) / 100);
rp->x = x + FLOATRAND(multi * 7.6, multi * 8.4);
rp->y = pp->height - 1;
if (MI_WIN_IS_USE3D(mi)) {
rp->zvel = FLOATRAND(zvel * 0.97, zvel * 1.03);
rp->z = z;
}
rp->nstars = nstars;
}
}
static void
animate(ModeInfo * mi, pyrostruct * pp, rocket * rp)
{
int starn, diff;
float r, theta;
if (rp->state == REDGLARE) {
shootup(mi, pp, rp);
/* Handle setup for explosion */
if (rp->state == BURSTINGINAIR) {
for (starn = 0; starn < rp->nstars; starn++) {
rp->stars[starn].sx = rp->stars[starn].sy = 0.0;
if (MI_WIN_IS_USE3D(mi)) {
rp->stars[starn].sz = 0.0;
diff = (int) GETZDIFF(rp->z);
rp->Xpoints[0][starn].x = (int) rp->x + diff;
rp->Xpointsleft[0][starn].x = (int) rp->x - diff;
rp->Xpoints[0][starn].y =
rp->Xpointsleft[0][starn].y = (int) rp->y;
if (rp->shelltype & DOUBLECLOUD) {
rp->Xpoints[1][starn].x = (int) rp->x + diff;
rp->Xpointsleft[1][starn].x = (int) rp->x - diff;
rp->Xpoints[1][starn].y =
rp->Xpointsleft[1][starn].y = (int) rp->y;
}
/* this isn't really a 3d direction. it's */
/* very much the same as in worm. */
r = FLOATRAND(0.0, pp->maxsvel);
theta = FLOATRAND(0.0, TWOPI);
rp->stars[starn].sxvel = r * COSF(theta);
rp->stars[starn].syvel = r * SINF(theta);
theta = FLOATRAND(0.0, TWOPI);
rp->stars[starn].szvel = FLOATRAND(0.0, pp->maxsvel) * SINF(theta);
} else {
rp->Xpoints[0][starn].x = (int) rp->x;
rp->Xpoints[0][starn].y = (int) rp->y;
if ((rp->shelltype & COLORCLOUD) && (MI_NPIXELS(mi) > 2)) {
if (NRAND(6) < 1)
rp->stars[starn].color = MI_WHITE_PIXEL(mi);
else
rp->stars[starn].color = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
}
if (rp->shelltype & DOUBLECLOUD) {
rp->Xpoints[1][starn].x = (int) rp->x;
rp->Xpoints[1][starn].y = (int) rp->y;
}
r = FLOATRAND(0.0, pp->maxsvel);
theta = FLOATRAND(0.0, TWOPI);
rp->stars[starn].sxvel = r * COSF(theta);
rp->stars[starn].syvel = r * SINF(theta);
}
/* This isn't accurate solid geometry, but it looks OK. */
}
rp->fuse = INTRAND(MINSFUSE, MAXSFUSE);
}
}
if (rp->state == BURSTINGINAIR) {
burst(mi, pp, rp);
}
}
static void
shootup(ModeInfo * mi, pyrostruct * pp, rocket * rp)
{
Display *display = MI_DISPLAY(mi);
Window window = MI_WINDOW(mi);
GC gc = MI_GC(mi);
int diff, h;
if (MI_WIN_IS_INSTALL(mi) && MI_WIN_IS_USE3D(mi))
XSetForeground(display, gc, MI_NONE_COLOR(mi));
else
XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
if (MI_WIN_IS_USE3D(mi)) {
diff = (int) GETZDIFF(rp->z);
XFillRectangle(display, window, gc, (int) (rp->x) + diff, (int) (rp->y),
ROCKETW, ROCKETH + 3);
XFillRectangle(display, window, gc, (int) (rp->x) - diff, (int) (rp->y),
ROCKETW, ROCKETH + 3);
} else
XFillRectangle(display, window, gc, (int) (rp->x), (int) (rp->y),
ROCKETW, ROCKETH + 3);
if (rp->fuse-- <= 0) {
rp->state = BURSTINGINAIR;
return;
}
rp->x += rp->xvel;
rp->y += rp->yvel;
rp->yvel += pp->rockdecel;
if (MI_WIN_IS_USE3D(mi)) {
INCZ(rp->z, rp->zvel);
diff = (int) GETZDIFF(rp->z);
h = (int) (ROCKETH + NRAND(4));
if (MI_WIN_IS_INSTALL(mi))
XSetFunction(display, gc, GXor);
XSetForeground(display, gc, MI_RIGHT_COLOR(mi));
XFillRectangle(display, window, gc, (int) (rp->x) + diff, (int) (rp->y),
ROCKETW, h);
XSetForeground(display, gc, MI_LEFT_COLOR(mi));
XFillRectangle(display, window, gc, (int) (rp->x) - diff, (int) (rp->y),
ROCKETW, h);
if (MI_WIN_IS_INSTALL(mi))
XSetFunction(display, gc, GXcopy);
} else {
XSetForeground(display, gc, pp->rockpixel);
XFillRectangle(display, window, gc, (int) (rp->x), (int) (rp->y),
ROCKETW, (int) (ROCKETH + NRAND(4)));
}
}
static void
burst(ModeInfo * mi, pyrostruct * pp, rocket * rp)
{
Display *display = MI_DISPLAY(mi);
Window window = MI_WINDOW(mi);
GC gc = MI_GC(mi);
register int starn;
register int nstars, stype;
register float rx, ry, rz = 0.0, sd; /* Help compiler optimize :-) */
register float sx, sy, sz;
int diff;
nstars = rp->nstars;
stype = rp->shelltype;
if (MI_WIN_IS_INSTALL(mi) && MI_WIN_IS_USE3D(mi))
XSetForeground(display, gc, MI_NONE_COLOR(mi));
else
XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
XFillRectangles(display, window, gc, rp->Xpoints[0], nstars);
if (stype & DOUBLECLOUD)
XFillRectangles(display, window, gc, rp->Xpoints[1], nstars);
if (MI_WIN_IS_USE3D(mi)) {
XFillRectangles(display, window, gc, rp->Xpointsleft[0], nstars);
if (stype & DOUBLECLOUD)
XFillRectangles(display, window, gc, rp->Xpointsleft[1], nstars);
}
if (rp->fuse-- <= 0) {
rp->state = SILENT;
pp->nflying--;
return;
}
/* Stagger the stars' decay */
if (rp->fuse <= 7) {
if ((rp->nstars = nstars = nstars * 90 / 100) == 0)
return;
}
rx = rp->x;
ry = rp->y;
if (MI_WIN_IS_USE3D(mi)) {
rz = rp->z;
}
sd = pp->stardecel;
for (starn = 0; starn < nstars; starn++) {
sx = rp->stars[starn].sx += rp->stars[starn].sxvel;
sy = rp->stars[starn].sy += rp->stars[starn].syvel;
rp->stars[starn].syvel += sd;
if (MI_WIN_IS_USE3D(mi)) {
if (rz + rp->stars[starn].sz + rp->stars[starn].szvel > MINZVAL)
rp->stars[starn].sz += rp->stars[starn].szvel;
sz = rp->stars[starn].sz;
diff = (int) GETZDIFF(rz + sz);
rp->Xpoints[0][starn].x = (int) (rx + sx + diff);
rp->Xpointsleft[0][starn].x = (int) (rx + sx - diff);
rp->Xpoints[0][starn].y =
rp->Xpointsleft[0][starn].y = (int) (ry + sy);
if (stype & DOUBLECLOUD) {
rp->Xpoints[1][starn].x = (int) (rx + 1.7 * sx) + diff;
rp->Xpointsleft[1][starn].x = (int) (rx + 1.7 * sx) - diff;
rp->Xpoints[1][starn].y =
rp->Xpointsleft[1][starn].y = (int) (ry + 1.7 * sy);
}
} else {
rp->Xpoints[0][starn].x = (int) (rx + sx);
rp->Xpoints[0][starn].y = (int) (ry + sy);
if (stype & DOUBLECLOUD) {
rp->Xpoints[1][starn].x = (int) (rx + 1.7 * sx);
rp->Xpoints[1][starn].y = (int) (ry + 1.7 * sy);
}
}
}
rp->x = rx + rp->xvel;
rp->y = ry + rp->yvel;
if (MI_WIN_IS_USE3D(mi)) {
rp->z = ADDZ(rz, rp->zvel);
}
rp->yvel += sd;
if (MI_WIN_IS_USE3D(mi)) {
if (MI_WIN_IS_INSTALL(mi))
XSetFunction(display, gc, GXor);
XSetForeground(display, gc, MI_RIGHT_COLOR(mi));
XFillRectangles(display, window, gc, rp->Xpoints[0], nstars);
if (stype & DOUBLECLOUD) {
XFillRectangles(display, window, gc, rp->Xpoints[1], nstars);
}
XSetForeground(display, gc, MI_LEFT_COLOR(mi));
XFillRectangles(display, window, gc, rp->Xpointsleft[0], nstars);
if (stype & DOUBLECLOUD) {
XFillRectangles(display, window, gc, rp->Xpointsleft[1], nstars);
}
if (MI_WIN_IS_INSTALL(mi))
XSetFunction(display, gc, GXcopy);
} else {
if ((stype & COLORCLOUD) && (MI_NPIXELS(mi) > 2)) {
for (starn = 0; starn < nstars; starn++) {
XSetForeground(display, gc, rp->stars[starn].color);
XFillRectangle(display, window, gc,
rp->Xpoints[0][starn].x, rp->Xpoints[0][starn].y,
rp->Xpoints[0][starn].width, rp->Xpoints[0][starn].height);
}
} else {
XSetForeground(display, gc, rp->color[0]);
XFillRectangles(display, window, gc, rp->Xpoints[0], nstars);
}
if (stype & DOUBLECLOUD) {
XSetForeground(display, gc, rp->color[1]);
XFillRectangles(display, window, gc, rp->Xpoints[1], nstars);
}
}
}
void
init_pyro(ModeInfo * mi)
{
pyrostruct *pp;
rocket *rp;
int rockn, starn;
int size = MI_SIZE(mi);
if (pyros == NULL) {
if ((pyros = (pyrostruct *) calloc(MI_NUM_SCREENS(mi),
sizeof (pyrostruct))) == NULL)
return;
}
pp = &pyros[MI_SCREEN(mi)];
pp->width = MI_WIN_WIDTH(mi);
pp->height = MI_WIN_HEIGHT(mi);
pp->lmargin = pp->width / 16;
pp->rmargin = pp->width - pp->lmargin;
pp->nrockets = MI_BATCHCOUNT(mi);
if (pp->nrockets < -MINROCKETS) {
if (pp->rockq) {
(void) free((void *) pp->rockq);
pp->rockq = NULL;
}
pp->nrockets = NRAND(-pp->nrockets - MINROCKETS + 1) + MINROCKETS;
} else if (pp->nrockets < MINROCKETS)
pp->nrockets = MINROCKETS;
if (size < -MINSIZE)
pp->star_size = NRAND(MIN(-size, MAX(MINSIZE,
MIN(pp->width, pp->height) / 64)) - MINSIZE + 1) + MINSIZE;
else if (size < MINSIZE) {
if (!size)
pp->star_size = MAX(MINSIZE, MIN(pp->width, pp->height) / 64);
else
pp->star_size = MINSIZE;
} else
pp->star_size = MIN(size, MAX(MINSIZE, MIN(pp->width, pp->height) / 64));
orig_p_ignite = P_IGNITE / pp->nrockets;
if (orig_p_ignite <= 0)
orig_p_ignite = 1;
pp->p_ignite = orig_p_ignite;
if (!pp->rockq) {
pp->rockq = (rocket *) malloc(pp->nrockets * sizeof (rocket));
}
pp->nflying = pp->fusilcount = 0;
for (rockn = 0, rp = pp->rockq; rockn < pp->nrockets; rockn++, rp++) {
rp->state = SILENT;
for (starn = 0; starn < MAXSTARS; starn++) {
rp->Xpoints[0][starn].width = rp->Xpoints[0][starn].height =
rp->Xpoints[1][starn].width = rp->Xpoints[1][starn].height =
pp->star_size;
if (MI_WIN_IS_USE3D(mi)) {
rp->Xpointsleft[0][starn].width = rp->Xpointsleft[0][starn].height =
rp->Xpointsleft[1][starn].width = rp->Xpointsleft[1][starn].height =
pp->star_size;
}
}
}
if (MI_NPIXELS(mi) > 3)
pp->rockpixel = MI_PIXEL(mi, ORANGE);
else
pp->rockpixel = MI_WHITE_PIXEL(mi);
/* Geometry-dependent physical data: */
pp->maxvelx = (float) (pp->width) * XVELFACTOR;
pp->minvelx = -pp->maxvelx;
pp->minvely = -(float) (pp->height) * MINYVELFACTOR;
pp->maxvely = -(float) (pp->height) * MAXYVELFACTOR;
if (MI_WIN_IS_USE3D(mi)) {
pp->maxvelz = (float) (MAXZVALSTART - MINZVALSTART) * ZVELFACTOR;
pp->minvelz = -pp->maxvelz;
}
pp->maxsvel = pp->minvely * SVELFACTOR;
pp->rockdecel = (float) (pp->height) * GRAVFACTOR;
pp->stardecel = pp->rockdecel * BOUYANCY;
if (MI_WIN_IS_INSTALL(mi) && MI_WIN_IS_USE3D(mi)) {
MI_CLEARWINDOWCOLOR(mi, MI_NONE_COLOR(mi));
} else {
MI_CLEARWINDOW(mi);
}
}
/* ARGSUSED */
void
draw_pyro(ModeInfo * mi)
{
pyrostruct *pp = &pyros[MI_SCREEN(mi)];
rocket *rp;
int rockn;
if (just_started || (NRAND(pp->p_ignite) == 0)) {
just_started = False;
if (NRAND(P_FUSILLADE) == 0) {
pp->p_ignite = orig_p_ignite / FUSILFACTOR;
if (pp->p_ignite <= 0)
pp->p_ignite = 1;
pp->fusilcount = INTRAND(FUSILLEN * 9 / 10, FUSILLEN * 11 / 10);
}
ignite(mi, pp);
if (pp->fusilcount > 0) {
if (--pp->fusilcount == 0)
pp->p_ignite = orig_p_ignite;
}
}
for (rockn = pp->nflying, rp = pp->rockq; rockn > 0; rp++) {
if (rp->state != SILENT) {
animate(mi, pp, rp);
rockn--;
}
}
}
void
release_pyro(ModeInfo * mi)
{
if (pyros != NULL) {
int screen;
for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
pyrostruct *pp = &pyros[screen];
if (pp->rockq != NULL) {
(void) free((void *) pp->rockq);
}
}
(void) free((void *) pyros);
pyros = NULL;
}
}
void
refresh_pyro(ModeInfo * mi)
{
/* Do nothing, it will refresh by itself */
}
|