version: stringSet the master volume
volume: numberCreate a new Sound
The current supported formats are: mp3, ogg, wav and flac
filename: stringSound: userdataPlay the current sound
Pause the current sound (don’t rewind)
Stop the current sound (rewind sound)
Set and get the volume of the sound
volume: numbervolume: numberGet if sound is playing
playing: booleanGet if sound is paused
paused: booleanfunction tico.load()
sound = tico.audio.newSound("sound.mp3")
end
function tico.update(dt)
if tico.input.isDown("mouse1") then sound:play() end
end
Return true if the key/mouse button with the given name is pressed
name: string (see input names)isDown: booleanReturn true if the key/mouse button with the given name was pressed
name: string (see input names)isPressed: booleanReturn true if the key/mouse button with the given name is not pressed
name: string (see input names)isUp: booleanReturn true if the key/mouse button with the given name was released
name: string (see input names)isReleased: booleanReturn true if the given key is pressed
key: string (see input names)isKeyDown: booleanReturn true if the given key was pressed
key: string (see input names)isKeyPressed: booleanReturn true if the given key is not pressed
key: string (see input names)isKeyUp: booleanReturn true if the given key was released
key: string (see input names)isKeyReleased: booleanReturn true if the given mouse button is pressed
button: string (see input names)isMouseDown: booleanReturn true if the given mouse button was pressed
button: number (see input names)isMousePressed: booleanReturn true if the given mouse button is not pressed
button: number (see input names)isMouseUp: booleanReturn true if the given mouse button was released
button: number (see input names)isReleased: booleanReturn true if the joystick/gamepad button is pressed, jid is the number of the joystick
jid: numbername: string (see input names)isJoyDown: booleanReturn true if the joystick/gamepad button was pressed, jid is the number of the joystick
jid: numbername: string (see input names)isJoyPressed: booleanReturn true if the joystick/gamepad button is not pressed, jid is the number of the joystick
jid: numbername: string (see input names)isJoyUp: booleanReturn true if the joystick/gamepad button was released, jid is the number of the joystick
jid: numbername: string (see input names)isJoyReleased: booleanReturn the linear interpolation between init and end for the given t
init: numberend: numbert: numberlerpVal: numberBounds v between min and max.
if x < min returns min
if x > max returns max
v: numbermin: numbermax: numberval: numberRound value
value: numberroundedNumber: numberSign value
if x < 0 return -1
if x > 0 return 1
if x == 0 return 0
value: numbersignedValue: numberReturns the distance between val1 and val2
val1: numberval2: numberdistance: numberReturn the angle between the two points
x0: numbery0: numberx1: numbery1: numberangle: numberRead content from file
filename: stringfile_content: stringWrite content to file, if file don’t exists, create one.
filename: stringtext: stringmode: string (“w”)Check if the file exists
filename: string
fileExists: booleanGet the current project path
project_path: stringGet the exe path
exe_path: stringResolve the filename using the current project_path
filename: stringresolved_path: stringCreate a directory
name: stringRemove a directory
name: stringEncodes a Lua table in a JSON string
table: tablejson_string: stringDecodes a JSON string to a Lua table
str: stringtable: tableLoad a JSON file to a Lua table
filename: stringtable: tableSave a Lua table to a JSON file
filename: stringtable: tableGet window title
title: stringSet window title
title: stringGet window width
width: numberSet window width
width: numberGet window height
height: numberSet window height
height: numberGet window size
width: numberheight: numberReturn the current delta time
delta: numberReturn the current FPS
fps: numberReturns the current window size
width: numberheight: numberlocal w, h = tico.graphics.getSize()
Clear the current framebuffer
If none argument is passed, clear to black
r: numberg: numberb: numbera: number (255)color: table ({0, 0, 0})function tico.draw()
tico.graphics.clear(255, 0, 0)
end
Color = require "tico.color"
function tico.draw()
tico.graphics.clear(Color.Red)
end
function tico.draw()
tico.graphics.clear({255, 0, 0})
end
Create a new canvas (OpenGL framebuffer)
width: numberheight: numberCanvas: userdataDraw the canvas
All arguments are optional
x: number (0)y: number (0)angle: number (0)scaleX: number (1)scaleY: number (1)centerX: number (0)centerY: number (0)color: table ({255, 255, 255})Draw canvas and auto scale to fit window size but maintain the ratio
Get the canvas texture width
width: numberGet the canvas texture height
height: numberGet the canvas texture size
width: numberheight: numberAttach the Canvas
Detach the Canvas, backing to the default framebuffer
function tico.load()
canvas = tico.graphics.newCanvas(320, 240)
end
function tico.draw()
canvas:attach()
tico.graphics.clear()
tico.graphics.drawRectangle(0, 0, 32, 32)
canvas:detach()
canvas:auto()
end
Creates a new image
filename: stringImage: userdataDraw the image
All arguments are optional
x: number (0)y: number (0)angle: number (0)scaleX: number (1)scaleY: number (1)centerX: number (0)centerY: number (0)color: table ({255, 255, 255})Get the image’s width
width: numberGet the image’s height
height: numberGet the image’s size
width: numberheight: numberfunction tico.load()
image = tico.graphics.newImage("image.png")
end
function tico.draw()
image:draw(32, 32)
end
Creates a new Rectangle
x: numbery: numberw: numberh: numberRectangle: userdataGet the rectangle width
width: numberGet the rectangle height
height: numberGet the rectangle x
x: numberGet the rectangle y
y: numberDraw a lined rectangle
x: numbery: numberw: numberh: numbercolor: table ({255, 255, 255})Draw a filled rectangle
x: numbery: numberw: numberh: numbercolor: table ({255, 255, 255})Draw a lined circle
x: numbery: numberradius: numbercolor: table ({255, 255, 255})Draw a filled circle
x: numbery: numberradius: numbercolor: table ({255, 255, 255})Draw a lined triangle
x0, x1, x2: numbery0, y1, y2: numbercolor: table ({255, 255, 255})Draw a lined triangle
x0, x1, x2: numbery0, y1, y2: numbercolor: table ({255, 255, 255})Draw a line
-args:
- x0, x1: number
- y0, y1: number
- color: table ({255, 255, 255})
Set a scissor
x: numbery: numberw: numberh: numberDraw text on the screen
font: Font (defaultFont)text: stringx: numbery: numbercolor: numberextended tico.graphics.print
sx and sy are the scale factor
font: Font (defaultFont)text: stringx: numbery: numbersx: numbersy: numbercolor: number