static void launch (int xlim, int ylim, int g) { struct projectile *p = get_projectile (); int x, dx, xxx; double red, green, blue; if (! p) return; do { x = (myrand() % xlim); dx = 30000 - (myrand() % 60000); xxx = x + (dx * 200); } while (xxx <= 0 || xxx >= xlim); p->x = x; p->y = ylim; p->dx = dx; p->size = 20000; p->decay = 0; p->dy = (myrand() % 10000) - 20000; p->fuse = ((((myrand() % 500) + 100) * abs (p->dy / g)) / 1000); p->primary = true; hsv_to_rgb ((double)(myrand() % 360)/360.0, 1.0, 255.0, &red, &green, &blue); //printf("New Projectile at (%d, %d), d(%d, %d), colour(%d,%d,%d)", x, ylim, dx, p->dy, (int)red, (int)green, (int)blue); p->colour = D3DCOLOR_XRGB((int)red,(int)green,(int)blue); return; }
static struct projectile *shrapnel(struct projectile *parent) { struct projectile *p = get_projectile (); if (! p) return 0; p->x = parent->x; p->y = parent->y; p->dx = (myrand() % 5000) - 2500 + parent->dx; p->dy = (myrand() % 5000) - 2500 + parent->dy; p->decay = (myrand() % 50) - 60; p->size = (parent->size * 2) / 3; p->fuse = 0; p->primary = false; p->colour = parent->colour; return p; }
static void launch (struct state *st, int xlim, int ylim, int g) { struct projectile *p = get_projectile (st); int x, dx, xxx; if (! p) return; do { x = (random () % xlim); dx = 30000 - (random () % 60000); xxx = x + (dx * 200); } while (xxx <= 0 || xxx >= xlim); p->x = x; p->y = ylim; p->dx = dx; p->size = 8000; p->decay = 0; p->dy = (random () % 4000) - 13000; p->fuse = ((((random () % 500) + 500) * abs (p->dy / g)) / 1000); p->primary = True; /* cope with small windows -- those constants assume big windows. */ { int dd = 1000000 / ylim; if (dd > 1) p->fuse /= dd; } if (! mono_p) { hsv_to_rgb (random () % 360, 1.0, 1.0, &p->color.red, &p->color.green, &p->color.blue); p->color.flags = DoRed | DoGreen | DoBlue; if (!XAllocColor (st->dpy, st->cmap, &p->color)) { p->color.pixel = WhitePixel (st->dpy, DefaultScreen (st->dpy)); p->color.red = p->color.green = p->color.blue = 0xFFFF; } } }
static struct projectile * shrapnel (struct state *st, struct projectile *parent) { struct projectile *p = get_projectile (st); int v; if (! p) return 0; p->x = parent->x; p->y = parent->y; v=random () % PI_2000; p->dx =(st->sin_cache[v]) + parent->dx; p->dy =(st->cos_cache[v]) + parent->dy; p->decay = (random () % 50) - 60; p->size = (parent->size * 2) / 3; p->fuse = 0; p->primary = False; p->color = parent->color; if (! mono_p) XAllocColor (st->dpy, st->cmap, &p->color); /* dup the lock */ return p; }