-void
-new_rocks(void)
-{
- int i,j;
- float ti[4];
- float x, y;
-
- 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;
- }
-
- j=0;
- do {
- rockptr->dx = RDX*crnd();
- rockptr->dy = RDY*crnd();
- x = (rockptr->dx-screendx)*gamerate;
- y = (rockptr->dy-screendy)*gamerate;
- j++;
- } while(x < -rockptr->image->w || x >= XSIZE
- || y < -rockptr->image->h || y >= YSIZE);
- if(j > 1) fprintf(stderr, "had to try %d times.\n", j);
-
- rockptr->active = 1;
- }
- }
- }