PhysicsAPI reference
Class TileMotion
Namespace: MicroEngine.World
Assembly: MicroEngine.Physics.Tiles.dll
Guide: Tile maps and collision
Moves an axis-aligned box through a tile grid (plus optional extra solid rectangles such as moving platforms or push blocks). X is resolved before Y, each as a swept test in sub-steps no larger than half a tile: the box stops flush against the first solid tile or rectangle in its way, however thin, so it never tunnels. One-way tiles only stop bodies falling onto their top edge.
public static class TileMotionInheritance
Remarks
A stateless convenience over one grid, for a game that moves its own boxes. A world of bodies, sensors, queries and moving solids that push and carry bodies is the tile backend of the physics contract, TilePhysicsWorld2D, built on the same swept test.
Methods
IsOnGround(RectF, ICollisionGrid, IReadOnlyList<RectF>?, bool)
True when a 1px probe directly below the box would collide (standing on ground or a platform).
public static bool IsOnGround(RectF box, ICollisionGrid grid, IReadOnlyList<RectF>? solids = null, bool ignoreOneWay = false)Parameters
box RectF
grid ICollisionGrid
solids IReadOnlyList<RectF>?
ignoreOneWay bool
Returns
IsSolidAt(Vector2, ICollisionGrid)
Whether the tile under point (world pixels) is solid. One-way tiles do not count.
public static bool IsSolidAt(Vector2 point, ICollisionGrid grid)Parameters
point Vector2
grid ICollisionGrid
Returns
Move(RectF, Vector2, ICollisionGrid, IReadOnlyList<RectF>?, bool)
Moves box by delta, stopping flush against solid tiles, one-way tiles (from above) and solids.
public static TileMoveResult Move(RectF box, Vector2 delta, ICollisionGrid grid, IReadOnlyList<RectF>? solids = null, bool ignoreOneWay = false)Parameters
box RectF
The body’s hitbox in world pixels.
delta Vector2
Movement in pixels for this step (velocity × dt).
grid ICollisionGrid
The tiles to collide with.
solids IReadOnlyList<RectF>?
Extra solid rectangles. One the box already overlaps before moving does not block it, so a body is never trapped inside it, except a rectangle that rose into a box moving down: when its top edge is inside the box’s lower half, the box is first lifted onto it (if nothing solid is there), as a platform carries what stands on it.
ignoreOneWay bool
Passes through one-way tiles (dropping down through a platform).
Returns
The new box and what it hit. On a hit, movement along that axis stops for the rest of this step.
Exceptions
delta is not finite.
TouchedFlags(RectF, ICollisionGrid)
Union of flags of every tile overlapping the box.
public static TileFlags TouchedFlags(RectF box, ICollisionGrid grid)Parameters
box RectF
grid ICollisionGrid