🎮 COLLISION#
ANTIRUINS provides a simple collision system that can be used for basic collision detection.
It currently handles AABB to AABB and AABB to Circle collisions.
Note
As of now, you can find multiple edition of bump in the lib
folder.
bump_c2.lua is the most recent and recommended version.
Since most of these function takes the world as their first argument, you can use these function as methods of the world object.
local item = {} -- this can be any table in your game, it could be a texture table, a player table, etc.
bump.add(world, item, x, y, w, h)
--is the same as
world:add(item, x, y, w, h)
local collision --the object it collided with.
local dX, dY = 10, 10 -- the amount of movement you want to apply to the item.
item.x, item.y, collision = world:move(item, dX, dY, bump.SOLID) -- world:move with return where the item actually is after the move.
Creates a new world object.
cellSize
define the size of each cell for grid spatial partitioning.
Adds a new Box (AABB) collider to the world. Returns
Adds a new Circle collider to the world.
Removes an item from the world.
Updates the position of an item.
This doesn't check for collision, but updates the rigidbody position.
w
and h
are optional, if you don't provide them, the item will keep its previous size.
Moves an item to the specified position.
Response must be either bump.SOLID (default) or bump.CROSS.
Returns
newX, newY, collisionObject
.
Checks if
item
is colliding with something.
Returns collisionObject
.
Returns the rectangle
x, y, w, h
of an item.
Note
You can visualise your collider by using the draw
function.
Returns the collider of an item.
Returns all colliders in the world.