for(i=0; i<MAXBANGDOTS; i++) {
if(!bdot[i].active) continue;
- // If the dot has drifted outside the screen, kill it
+ // decrement life and maybe kill
+ bdot[i].life -= bdot[i].decay;
+ if(bdot[i].life<0) { bdot[i].active = 0; continue; }
+
+ // move and clip
+ bdot[i].x += bdot[i].dx*t_frame - xscroll;
+ bdot[i].y += bdot[i].dy*t_frame - yscroll;
if(bdot[i].x < 0 || bdot[i].x >= XSIZE || bdot[i].y < 0 || bdot[i].y >= YSIZE) {
bdot[i].active = 0;
continue;
}
+
+ // check collisions
if(pixel_hit_rocks(bdot[i].x, bdot[i].y)) { bdot[i].active = 0; continue; }
+
pixel = pixels + row_inc*(int)(bdot[i].y) + (int)(bdot[i].x);
if(bdot[i].c) c = bdot[i].c; else c = heatcolor[(int)(bdot[i].life)*3];
*pixel = c;
- bdot[i].life -= bdot[i].decay;
- bdot[i].x += bdot[i].dx*t_frame - xscroll;
- bdot[i].y += bdot[i].dy*t_frame - yscroll;
-
- if(bdot[i].life<0) bdot[i].active = 0;
}
}
}
int
-pixel_hit_rocks(float x, float y)
+pixel_hit_in_bucket(int b, float x, float y)
{
- int b;
struct rock_struct *r;
-
- b = bucket(x, y);
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)
{
if(xoff >= r->w || yoff >= r->h) return 0;
- pmask = 1 << (xoff & 31); xoff >>= 5;
- return r->mask[yoff*r->mw + xoff] & pmask;
+ pmask = 1 << (32 - (xoff&0x1f));
+ return r->mask[(yoff*r->mw) + (xoff>>5)] & pmask;
}