Skip to main content

Crate o_centored_attack

Crate o_centored_attack 

Source
Expand description

Checked, deterministic vertical-strike resolution for 2D games.

Positive Y points upward. A downward attack therefore produces a negative Y impulse, while an upward attack produces a positive Y impulse. Horizontal impulse is always zero.

use o_centored_attack::{
    AttackOutcome, AxisPoint, TargetBox, VerticalAttack, VerticalDirection,
};

let attack = VerticalAttack::new(
    AxisPoint::new(0, 100),
    VerticalDirection::Down,
    100,
    10,
    1_000,
)?;
let target = TargetBox::new(AxisPoint::new(0, 20), 10, 10);
assert!(matches!(attack.resolve(&target)?, AttackOutcome::Hit(_)));

Structs§

AxisPoint
Integer point in an axis-aligned 2D world.
Impact
Contact and impulse details for a hit.
TargetBox
Axis-aligned target bounds described by a center and half extents.
VerticalAttack
A vertical attack column originating at one point.

Enums§

AttackError
Invalid attack configuration or checked-arithmetic failure.
AttackOutcome
Result of resolving one attack against one target.
MissReason
Why a geometrically valid resolution did not hit.
VerticalDirection
Vertical direction of travel and impulse.