- 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(struct rock_struct *r, float x, float y, struct shape *shape)
-{
- for(; 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 ix, iy;
- int l, r, t, b;
- struct rock_struct **bucket;
-
- ix = x + grid_size; iy = y + grid_size;
- l = ix / grid_size; r = (ix+shape->w)/grid_size;
- t = iy / grid_size; b = (iy+shape->h)/grid_size;
- bucket = &rock_buckets[p][l + t*bw];
-
- if(hit_in_bucket(*bucket, x, y, shape)) return true;
- if(l && hit_in_bucket(*(bucket-1), x, y, shape)) return true;
- if(r && hit_in_bucket(*(bucket-bw), x, y, shape)) return true;
- if(l && r && hit_in_bucket(*(bucket-(1+bw)), x, y, shape)) return true;
-
- if(r > l) {
- if(hit_in_bucket(*(bucket+1), x, y, shape)) return true;
- if(hit_in_bucket(*(bucket+1-bw), x, y, shape)) return true;
- }
- if(t > b) {
- if(hit_in_bucket(*(bucket+bw), x, y, shape)) return true;
- if(hit_in_bucket(*(bucket+bw-1), x, y, shape)) return true;
- }
- if(r > l && t > b && hit_in_bucket(*(bucket+bw+1), x, y, shape)) return true;
- return false;
-}
-
-int
-pixel_hit_in_bucket(struct rock_struct *r, float x, float y)
-{
- for(; 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)
-{
- struct rock_struct **b = bucket(x, y, p);
- 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;