o-centored-attack
o-centored-attack is a dependency-free 2D game-physics library for
resolving attacks constrained to a vertical axis.
The vertical-strike principle
This crate gives a concrete meaning to 垂直に叩く理:
Keep the strike impulse vertical, let horizontal offset decide centeredness, and transfer the greatest force only when the attack is centered.
Resolution distinguishes horizontal misses, targets on the wrong side, and targets beyond reach. All geometry and force calculations use checked integer arithmetic.
Example
use ;
let attack = new?;
let target = new;
let Hit = attack.resolve? else ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
Coordinates are unit-agnostic. Positive Y is up, so downward impulses are negative and upward impulses are positive.
This crate provides game geometry only; it does not apply damage or mutate game entities.
License
MIT