pub struct TargetBox { /* private fields */ }Expand description
Axis-aligned target bounds described by a center and half extents.
Implementations§
Source§impl TargetBox
impl TargetBox
Sourcepub const fn new(center: AxisPoint, half_width: u64, half_height: u64) -> Self
pub const fn new(center: AxisPoint, half_width: u64, half_height: u64) -> Self
Creates target bounds. Zero-sized extents are valid.
Examples found in repository?
examples/strike.rs (line 11)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let attack = VerticalAttack::new(
5 AxisPoint::new(0, 100),
6 VerticalDirection::Down,
7 100,
8 10,
9 1_000,
10 )?;
11 let target = TargetBox::new(AxisPoint::new(5, 20), 10, 10);
12
13 match attack.resolve(&target)? {
14 AttackOutcome::Hit(impact) => println!(
15 "hit: distance={}, centering={:.2}%, force={}, impulse=({}, {})",
16 impact.distance(),
17 f64::from(impact.centering_basis_points()) / 100.0,
18 impact.transmitted_force(),
19 impact.impulse_x(),
20 impact.impulse_y()
21 ),
22 AttackOutcome::Miss(reason) => println!("miss: {reason:?}"),
23 }
24
25 Ok(())
26}Sourcepub const fn half_width(self) -> u64
pub const fn half_width(self) -> u64
Horizontal half extent.
Sourcepub const fn half_height(self) -> u64
pub const fn half_height(self) -> u64
Vertical half extent.
Trait Implementations§
impl Copy for TargetBox
impl Eq for TargetBox
impl StructuralPartialEq for TargetBox
Auto Trait Implementations§
impl Freeze for TargetBox
impl RefUnwindSafe for TargetBox
impl Send for TargetBox
impl Sync for TargetBox
impl Unpin for TargetBox
impl UnsafeUnpin for TargetBox
impl UnwindSafe for TargetBox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more