blob: 04de4842b1828557e55835db447ce6a286dc0c61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
use geometry::*;
pub trait CircleHitbox {
fn pos(&self) -> Vec2d;
fn radius(&self) -> f64;
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)
}
}
|