Apply horizontal movement to an object's position and test if it will collide.
map.TestMoveX(x, y, w, h, newx)
x- Horizontal position of the rectangle.
y- Vertical position of the rectangle.
w- Width of the rectangle.
h- Height of the rectangle.
newx- New horizontal position of the rectangle.
A +/- integer offset that when added to `newx` will remove the object under test from collision. A zero value indicates no collision has occurred.
Knowing whether a collision has happened is often not enough,
as you might need to keep the player inside a known region.
map.TestMoveY allow you to test if a
potential horizontal or vertical movement will cause a
If so, it will return a correction factor needed to remove the object from the collision. In this way, you can build walls that players can slide along and won’t escape from.