-int
-hit_rocks(float x, float y, struct shape *shape)
-{
- int i;
-
- for(i=0; i<MAXROCKS; i++) {
- if(rock[i].active) {
- if(collide(x-rock[i].x, y-rock[i].y, rock[i].shape, shape))
- return 1;
+ rock_sides(ti, rmin, rmax);
+
+ // increment timers
+ for(i=0; i<4; i++) rtimers[i] += ti[i]*t_frame;
+
+ // generate rocks
+ for(i=0; i<4; i++) {
+ while(rtimers[i] >= 1) {
+ rtimers[i] -= 1;
+ if(!free_sprites[ROCK]) return; // sorry, we ran out of rocks!
+ r = (struct rock *) remove_sprite(&free_sprites[ROCK]);
+ type = urnd() % NROCKS;
+ *r = prototypes[type];
+ r->type = type;
+ r->life = r->area * 300;
+ switch(i) {
+ case RIGHT:
+ r->x = XSIZE;
+ r->y = frnd()*(YSIZE + r->image->h);
+
+ r->dx = -weighted_rnd_range(rmin[i], rmax[i]) + screendx;
+ r->dy = RDY*crnd();
+ break;
+ case LEFT:
+ r->x = -r->image->w;
+ r->y = frnd()*(YSIZE + r->image->h);
+
+ r->dx = weighted_rnd_range(rmin[i], rmax[i]) + screendx;
+ r->dy = RDY*crnd();
+ break;
+ case BOTTOM:
+ r->x = (frnd()*(XSIZE + r->image->w)) - r->image->w;
+ r->y = YSIZE;
+
+ r->dx = RDX*crnd();
+ r->dy = -weighted_rnd_range(rmin[i], rmax[i]) + screendy;
+ break;
+ case TOP:
+ r->x = (frnd() * (XSIZE + r->image->w)) - r->image->w;
+ r->y = -r->image->h;
+
+ r->dx = RDX*crnd();
+ r->dy = weighted_rnd_range(rmin[i], rmax[i]) + screendy;
+ break;
+ }
+ add_sprite(SPRITE(r));