-void
-new_rocks(void)
-{
- int i,j;
- float ti[4];
-
- rock_timer_increments(ti);
-
- for(i=0; i<4; i++) {
- rtimers[i] += ti[i]*gamerate/20;
- if(rtimers[i] >= 1) {
- j=0;
- while(rockptr->active && j<MAXROCKS) {
- if(++rockptr - rock >= MAXROCKS) rockptr = rock;
- j++;
- }
- if(!rockptr->active) {
- rtimers[i] -= 1;
- rockptr->type_number = random() % NROCKS;
- rockptr->image = surf_rock[rockptr->type_number];
- rockptr->shape = &rock_shapes[rockptr->type_number];
- switch(i) {
- case RIGHT:
- rockptr->x = XSIZE;
- rockptr->y = rnd()*(YSIZE + rockptr->image->h);
- break;
- case LEFT:
- rockptr->x = -rockptr->image->w;
- rockptr->y = rnd()*(YSIZE + rockptr->image->h);
- break;
- case BOTTOM:
- rockptr->x = rnd()*(XSIZE + rockptr->image->w);
- rockptr->y = YSIZE;
- break;
- case TOP:
- rockptr->x = rnd()*(XSIZE + rockptr->image->w);
- rockptr->y = -rockptr->image->h;
- break;
- }
-
- rockptr->dx = RDX*crnd();
- rockptr->dy = RDY*crnd();
-
- rockptr->active = 1;
- }
- }
- }
+float
+weighted_rnd_range(float min, float max) {
+ return sqrt(min * min + frnd() * (max * max - min * min));