¶
luxe
API (2025.1.2
)¶
luxe: sat2D
module¶
SAT2D¶
import "luxe: sat2D" for SAT2D
The SAT2D API is a collision and query API for the luxe: shape2D shapes and types. It implements the "separating axis theorom" for collision.
Note The return values in the API are not user friendly atm, this will improve. They return lists with various values packed inside.
- collide_shape(shape1:
Any
, shape2:Any
) - collide_shapes(shape:
Any
, list:Any
) - contains(shape:
Any
, point:Any
) - sweep_shape(shape1:
Any
, shape2:Any
, vel:Any
) - raycast_ray(ray1:
Any
, ray2:Any
) - raycast_rays(ray:
Any
, rays:Any
) - raycast_shape(ray:
Any
, shape:Any
) - raycast_shapes(ray:
Any
, shapes:Any
)
Any
, shape2: Any
)
¶unknown
Check if two
Shape2D
instances are colliding. Returns a result with several values in aList
.The results include a
separation
value for x and y axis, which is how much to moveshape1
to cancel out the overlap. An example of using this: move a playershape2D
collider, check for collision, and then move them back byseparation
so that they do not collide anymore.[ shape1, //the original shapes shape2, overlap, //amount the shapes overlap separation_x, //the amount to separate on the x axis separation_y, //the amount to separate on the y axis normal_x, //the normal of the collision normal_y //the amount to separate on the y axis ]
Any
, list: Any
)
¶unknown
Like
collide_shape
for details on the results, but checks multiple shapes against a single one. For exampleSAT2D.collide_shapes(player, walls)
, where walls is a list ofShape2D
to collide against.Note this returns a list of results, and each result is a list described by
collide_shape
.//:todo: example. see samples/wip/shape2D
Any
, point: Any
)
¶unknown
Returns true if the given
Shape2D
containspoint
.
Any
, shape2: Any
, vel: Any
)
¶unknown
Any
, ray2: Any
)
¶unknown
Any
, rays: Any
)
¶unknown
Any
, shape: Any
)
¶unknown
Any
, shapes: Any
)
¶unknown