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