X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=rocks.c;h=f68a57a2c4c69b816eb9259eab9460f1bd5e3435;hp=e098fa0ef40d14307af58069dcff0d6e7732d094;hb=2b5dd5bc0eb1739dd744de6f565d0f3a7ae02c95;hpb=a77978e0c9bc91ea3d7b192ce136621e78d4ec5b diff --git a/rocks.c b/rocks.c index e098fa0..f68a57a 100644 --- a/rocks.c +++ b/rocks.c @@ -301,8 +301,18 @@ hit_rocks(float x, float y, struct shape *shape) 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(hit_in_bucket(b-1, x, y, shape)) return 1; + if(hit_in_bucket(b-bw, x, y, shape)) return 1; + if(hit_in_bucket(b-bw-1, x, y, shape)) return 1; + + if(bdx) { + if(hit_in_bucket(b+1, x, y, shape)) return 1; + if(hit_in_bucket(b+1-bw, x, y, shape)) return 1; + } + if(bdy) { + if(hit_in_bucket(b+bw, x, y, shape)) return 1; + if(hit_in_bucket(b+bw-1, x, y, shape)) return 1; + } if(bdx && bdy && hit_in_bucket(b+bw+1, x, y, shape)) return 1; return 0; }