Revision 224
i must learn maths
ent.c | ||
---|---|---|
146 | 146 |
int (map_collides_gunner)(const map_t *p, gunner_t *shooter) { |
147 | 147 |
double radius = sprite_get_w(shooter->dude)/2.0; |
148 | 148 |
double shooter_x = gunner_get_x(shooter); |
149 |
for (double x = shooter_x - radius; x < shooter_x + radius; x += 1) { |
|
150 |
double y1 = sqrt(1 - x*x); |
|
149 |
double shooter_y = gunner_get_y(shooter); |
|
150 |
for (double x = -radius; x < radius; x += 1) { |
|
151 |
double y1 = sqrt(radius*radius - x*x); |
|
151 | 152 |
double y2 = -y1; |
152 |
if (map_collides_point(p, x, y1) || map_collides_point(p, x, y2)) return 1;
|
|
153 |
if (map_collides_point(p, shooter_x + x, shooter_y + y1) || map_collides_point(p, shooter_x + x, shooter_y + y2)) return 1;
|
|
153 | 154 |
} |
154 | 155 |
return 0; |
155 | 156 |
} |
Also available in: Unified diff