blob: bd4170e4570ffed45250c0fffdd70ddc31b6c75b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
use geometry::*;
pub trait CircleHitbox {
fn pos(&self) -> Vec2d;
fn radius(&self) -> f64;
/**
* True if the point is inside the hitbox
*/
fn touches_point(&self, point: Vec2d) -> bool {
self.pos().distance(point) <= self.radius()
}
fn touches_circle(&self, other: &CircleHitbox) -> bool {
self.pos().distance_squared(other.pos()) <= (self.radius() + other.radius()).powi(2)
}
}
|