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§
- Axis
Point - Integer point in an axis-aligned 2D world.
- Impact
- Contact and impulse details for a hit.
- Target
Box - Axis-aligned target bounds described by a center and half extents.
- Vertical
Attack - A vertical attack column originating at one point.
Enums§
- Attack
Error - Invalid attack configuration or checked-arithmetic failure.
- Attack
Outcome - Result of resolving one attack against one target.
- Miss
Reason - Why a geometrically valid resolution did not hit.
- Vertical
Direction - Vertical direction of travel and impulse.