Module blocks

Level creation and management using bump.

Some of the functions were inspired from kikito.

Functions

addBlock (id, x, y, w, h, drawable, layer, collidable, execOnInteract) Add object to the current level.
updateBlock (id, x, y, w, h, drawable, layer, collidable, execOnInteract) Modify object by ID.
moveBlock (id, goalx, goaly) Move object by ID.
removeBlock (id) Remove object by ID.
drawBlocks (layer) Draw every object of the level.
searchByID (id) Search level object by ID.
LoadLevel (lvl) Load levels from lua files.


Functions

addBlock (id, x, y, w, h, drawable, layer, collidable, execOnInteract)
Add object to the current level.

Parameters:

  • id The ID that we will use to search the object
  • x X coordinates
  • y Y coordinates
  • w Width
  • h Height
  • drawable Sprite that will be used for the object
  • layer The layer where the object needs to be. The player is between the third and the fourth layer
  • collidable Collide with player (default: true)
  • execOnInteract Function to execute when player interacts with the object

Returns:

    Object that has been created.
updateBlock (id, x, y, w, h, drawable, layer, collidable, execOnInteract)
Modify object by ID.

Parameters:

  • id The ID that we will use to search the object
  • x X coordinates
  • y Y coordinates
  • w Width
  • h Height
  • drawable Sprite that will be used for the object
  • layer The layer where the object needs to be. The player is between the third and the fourth layer
  • collidable Collide with player (default: true)
  • execOnInteract Function to execute when player interacts with the object
moveBlock (id, goalx, goaly)
Move object by ID.

Parameters:

  • id The ID that we will use to search the object
  • goalx Target position in X coordinates
  • goaly Target position in Y coordinates

Returns:

  1. New X value.
  2. New Y value.
  3. Objects that are colliding.
  4. Number of objects that collided.
removeBlock (id)
Remove object by ID.

Parameters:

  • id The ID that we will use to search the object
drawBlocks (layer)
Draw every object of the level. Put this inside love.draw()

Parameters:

  • layer The layer you want to draw. It will draw everything if the parameter is nil
searchByID (id)
Search level object by ID.

Parameters:

  • id The ID used for the search

Returns:

    The object you were searching. Returns nil if the object doesn't exist.
LoadLevel (lvl)
Load levels from lua files. In the level file return a table with an update(dt) function inside

Parameters:

  • lvl Lua file to load

Returns:

    Level functions.
generated by LDoc 1.4.6 Last updated 2021-02-27 10:51:51