Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Drawing Functions

akesi lili provides a comprehensive set of functions to manage colors, palettes, screen and camera settings, and drawing operations. These functions allow you to control the visual aspects of your game, from setting colors to drawing complex shapes and text.

clear

|color: Number|

Clears the entire screen with the specified color. Possible color values are 0, 1, 2, and 3.

Parameters

  • color: The color to fill the screen with.

Example

clear(1)

cam

|| or |x: Number, y: Number|

Sets the camera offset to the specified coordinates. When called without arguments, resets the camera to (0, 0).

Parameters

  • x: The x-coordinate for the camera offset (optional).
  • y: The y-coordinate for the camera offset (optional).

Example

cam(10, 15)
cam() # Reset to (0, 0)

tra

|| or |color: Number|

Defines a color to be transparent during drawing operations. When called without arguments, disables transparency. Possible color values are 0, 1, 2, and 3.

Parameters

  • color: The color to be made transparent (optional).

Example

tra(0) # Make color 0 transparent
tra() # Disable transparency

clip

|| or |x: Number, y: Number, width: Number, height: Number|

Restricts drawing operations to the specified rectangular area. When called without arguments, resets the clipping area.

Parameters

  • x: The x-coordinate of the top-left corner of the clipping area (optional).
  • y: The y-coordinate of the top-left corner of the clipping area (optional).
  • width: The width of the clipping area (optional).
  • height: The height of the clipping area (optional).

Example

clip(10, 10, 50, 50)
clip() # Reset clipping area

pix

|x: Number, y: Number, color: Number|

Draws a single pixel at the specified coordinates with the given color. Possible color values are 0, 1, 2, and 3.

Parameters

  • x: The x-coordinate of the pixel.
  • y: The y-coordinate of the pixel.
  • color: The color of the pixel.

Example

pix(5, 5, 2)

rect

|x0: Number, y0: Number, x1: Number, y1: Number, color: Number|

Draws a bordered rectangle defined by two opposite corners with the specified color. Possible color values are 0, 1, 2, and 3.

Parameters

  • x0: The x-coordinate of the first corner.
  • y0: The y-coordinate of the first corner.
  • x1: The x-coordinate of the opposite corner.
  • y1: The y-coordinate of the opposite corner.
  • color: The color of the rectangle border.

Example

rect(10, 10, 20, 20, 1)

fill_rect

|x0: Number, y0: Number, x1: Number, y1: Number, color: Number|

Draws a filled rectangle defined by two opposite corners with the specified color. Possible color values are 0, 1, 2, and 3.

Parameters

  • x0: The x-coordinate of the first corner.
  • y0: The y-coordinate of the first corner.
  • x1: The x-coordinate of the opposite corner.
  • y1: The y-coordinate of the opposite corner.
  • color: The color to fill the rectangle with.

Example

fill_rect(10, 10, 20, 20, 2)

circ

|x: Number, y: Number, radius: Number, color: Number|

Draws a bordered circle with the specified center, radius, and color. Possible color values are 0, 1, 2, and 3.

Parameters

  • x: The x-coordinate of the circle's center.
  • y: The y-coordinate of the circle's center.
  • radius: The radius of the circle.
  • color: The color of the circle border.

Example

circ(15, 15, 10, 3)

fill_circ

|x: Number, y: Number, radius: Number, color: Number|

Draws a filled circle with the specified center, radius, and color. Possible color values are 0, 1, 2, and 3.

Parameters

  • x: The x-coordinate of the circle's center.
  • y: The y-coordinate of the circle's center.
  • radius: The radius of the circle.
  • color: The color to fill the circle with.

Example

fill_circ(15, 15, 10, 1)

line

|x0: Number, y0: Number, x1: Number, y1: Number, color: Number|

Draws a line from one point to another with the specified color. Possible color values are 0, 1, 2, and 3.

Parameters

  • x0: The x-coordinate of the starting point.
  • y0: The y-coordinate of the starting point.
  • x1: The x-coordinate of the ending point.
  • y1: The y-coordinate of the ending point.
  • color: The color of the line.

Example

line(5, 5, 15, 15, 2)

txt

|text: String, x: Number, y: Number, color: Number|

Draws text at the specified coordinates with the given color. Possible color values are 0, 1, 2, and 3.

Parameters

  • text: The text to draw.
  • x: The x-coordinate of the text's starting position.
  • y: The y-coordinate of the text's starting position.
  • color: The color of the text.

Example

txt("Hello", 10, 10, 3)

pal

||

Returns the current active color palette as a string.

Returns

A string representing the active color palette (e.g., "gray", "green", "red", "purple", "catppuccin", "black_white", or "custom").

Example

active_palette = pal()

set_pal

|palette: String|

Sets the current active color palette.

Parameters

  • palette: The name of the palette to set. Valid values include "gray", "green", "red", "purple", "catppuccin", "black_white".

Example

set_pal("green")

spr

|sprite: Number, x: Number, y: Number| or |sprite: Number, x: Number, y: Number, flip_x: Bool, flip_y: Bool|

Draws a sprite from the sprite sheet at the specified coordinates with optional flipping.

Parameters

  • sprite: The index of the sprite to draw.
  • x: The x-coordinate to draw the sprite at.
  • y: The y-coordinate to draw the sprite at.
  • flip_x: Whether to flip the sprite horizontally (optional, defaults to false).
  • flip_y: Whether to flip the sprite vertically (optional, defaults to false).

Example

spr(5, 20, 20)
spr(5, 20, 20, true, false) # Flip horizontally

map

|cell_x: Number, cell_y: Number, screen_x: Number, screen_y: Number, cell_width: Number, cell_height: Number|

Draws a portion of the map at the specified screen coordinates with the given cell dimensions.

Parameters

  • cell_x: The x-coordinate of the map cell to start drawing from.
  • cell_y: The y-coordinate of the map cell to start drawing from.
  • screen_x: The x-coordinate on the screen to draw the map portion at.
  • screen_y: The y-coordinate on the screen to draw the map portion at.
  • cell_width: The width of the map portion in cells.
  • cell_height: The height of the map portion in cells.

Example

map(0, 0, 10, 10, 5, 5)

tile

|x: Number, y: Number|

Returns the index of the sprite at the specified map coordinates.

Parameters

  • x: The x-coordinate of the map cell.
  • y: The y-coordinate of the map cell.

Returns

The index of the sprite at the specified map coordinates (Number).

Example

sprite_index = tile(5, 5)

set_tile

|x: Number, y: Number, tile: Number|

Replaces the tile at the specified map coordinates with the given sprite index.

Parameters

  • x: The x-coordinate of the map cell.
  • y: The y-coordinate of the map cell.
  • tile: The index of the sprite to place.

Example

set_tile(5, 5, 3)