- SDL_Rect dest;
-
- for(i=0; i<MAXROCKS; i++) {
- if(!rocks[i].image) continue;
- dest.x = rocks[i].x; dest.y = rocks[i].y;
- SDL_BlitSurface(rocks[i].image,NULL,surf_screen,&dest);
- }
-}
-
-int
-hit_in_bucket(int b, float x, float y, struct shape *shape)
-{
- struct rock_struct *r;
-
- for(r=rock_buckets[p][b]; r; r=r->next) {
- if(collide(x - r->x, y - r->y, r->shape, shape)) return 1;
- }
- return 0;
-}
-
-int
-hit_rocks(float x, float y, struct shape *shape)
-{
- int b = bucket(x, y);
- int bdx = ((int)x+shape->w)/grid_size - (int)x/grid_size;
- int bdy = ((int)y+shape->h)/grid_size - (int)y/grid_size;
- if(hit_in_bucket(b, x, y, shape)) return 1;
- if(bdx && hit_in_bucket(b+1, x, y, shape)) return 1;
- if(bdy && hit_in_bucket(b+bw, x, y, shape)) return 1;
- if(bdx && bdy && hit_in_bucket(b+bw+1, x, y, shape)) return 1;
- return 0;
-}
-
-int
-pixel_hit_in_bucket(int b, float x, float y)
-{
- struct rock_struct *r;
- for(r=rock_buckets[p][b]; r; r=r->next) {
- if(x < r->x || y < r->y) continue;
- if(pixel_collide(x - r->x, y - r->y, r->shape)) return 1;
- }
- return 0;
-}
-
-int
-pixel_hit_rocks(float x, float y)
-{
- int b = bucket(x, y);
- if(pixel_hit_in_bucket(b, x, y)) return 1;
- if(pixel_hit_in_bucket(b-1, x, y)) return 1;
- if(pixel_hit_in_bucket(b-bw, x, y)) return 1;
- if(pixel_hit_in_bucket(b-bw-1, x, y)) return 1;
- return 0;
-}
-
-void
-blast_rocks(float x, float y, float radius, int onlyslow)
-{
- int b;
- struct rock_struct *r;
- float dx, dy, n;
-
- if(onlyslow) return;
-
- for(b=0; b<n_buckets; b++) {
- for(r=rock_buckets[p][b]; r; r=r->next) {
- if(r->x <= 0) continue;
-
- // This makes it so your explosion from dying magically doesn't leave
- // any rocks that aren't moving much on the x axis. If onlyslow is set,
- // only rocks that are barely moving will be pushed.
- if(onlyslow && (r->dx - screendx < -4 || r->dx - screendx > 3)) continue;
-
- dx = r->x - x;
- dy = r->y - y;
-
- n = sqrt(dx*dx + dy*dy);
- if(n < radius) {
- n *= 15;
- r->dx += 54.0*dx/n;
- r->dy += 54.0*dy/n;
- }
- }
- }