API reference
smgf
version: 1.0
smgf
smgf.audio
smgf.audio.clone
function smgf.audio.clone(sound: SMGFSound)
-> clone: SMGFSound
Creates a copy of a SMGFSound
.
smgf.audio.get_duration
function smgf.audio.get_duration(sound: SMGFSound)
-> Duration: number
Returns the duration of a sound in milliseconds.
@param sound
— Sound to pause
@return Duration
— in milliseconds
smgf.audio.get_gain
function smgf.audio.get_gain(sound: SMGFSound)
-> gain: number
Returns the gain ("volume") of a sound, which is a number from "0" (silence) to "2" (200%).
smgf.audio.get_loop
function smgf.audio.get_loop(sound: SMGFSound)
-> looped: boolean
Returns whether a sound is looped or not.
smgf.audio.get_master_gain
function smgf.audio.get_master_gain()
-> gain: number
Returns the output gain ("volume"), which is a value between "0" (silence) and "2" (200%).
@return gain
— Gain (value between "0" (silence) and "2" (200%))
smgf.audio.get_master_pause
function smgf.audio.get_master_pause()
-> paused: boolean
Returns the master pause.
smgf.audio.get_pan
function smgf.audio.get_pan(sound: SMGFSound)
-> pan: number
Returns the panning of a sound, which is a number from "-1" (left) to "1" (right).
smgf.audio.is_playing
function smgf.audio.is_playing(sound: SMGFSound)
-> playing: boolean
Returns whether a sound is playing or not.
smgf.audio.is_predecoded
function smgf.audio.is_predecoded(sound: SMGFSound)
-> predecoded: boolean
Returns whether a sound is predecoded or not.
smgf.audio.new
function smgf.audio.new(filename: string, predecoded?: boolean)
-> SMGFSound
Loads a sound file and returns a SMGFSound
. The second argument
controls whether the sound file should be predecoded in memory at load,
or decoded during playback ("streamed").
It is advised to predecode short sound files such as sound effects, and
stream longer sound files such as music.
SMGF only supports ogg vorbis and wav files by default (can be configured at build)
@param filename
— File path
@param predecoded
— Whether the sound file should be predecoded in memory at load or decoded during playback ("streamed"), defaults to true
smgf.audio.pause
function smgf.audio.pause(sound: SMGFSound)
Pauses the playback of a sound.
@param sound
— Sound to pause
See: smgf.audio.play to unpause the sound
smgf.audio.play
function smgf.audio.play(sound: SMGFSound)
Starts playing a sound.
@param sound
— Sound to play
smgf.audio.rewind
function smgf.audio.rewind(sound: SMGFSound)
Rewinds a sound.
@param sound
— Sound to rewind
smgf.audio.seek
function smgf.audio.seek(sound: SMGFSound, ms: number)
Modifies the playback position of a sound.
@param ms
— The position in milliseconds
smgf.audio.set_gain
function smgf.audio.set_gain(sound: SMGFSound, gain: number)
Modifies the gain ("volume") of a sound. Expects a number from "0" (silence) to "2" (200%). Default value is "0" (100%).
smgf.audio.set_loop
function smgf.audio.set_loop(sound: SMGFSound, looped: boolean)
Sets whether a sound should be looped or not.
smgf.audio.set_master_gain
function smgf.audio.set_master_gain(gain: number)
Sets the output gain ("volume"). Expects a value between "0" (silence) and "2" (200%). Default value is "1" (100%).
@param gain
— Gain (value between "0" (silence) and "2" (200%))
smgf.audio.set_master_pause
function smgf.audio.set_master_pause(paused: boolean)
Sets the master pause: when enabled, all sound will pause until re-enabled.
smgf.audio.set_pan
function smgf.audio.set_pan(sound: SMGFSound, pan: number)
Modifies the panning of a sound. Expects a number from "-1" (left) to "1" (right). Default value is "0" (center).
smgf.device_reset
Callback, called on SDL_RENDER_DEVICE_RESET event.
fun()
smgf.draw
Callback, called every frame after smgf.update
. All drawing operations should be done here.
fun()
smgf.focus
Callback, called when the smgf window loses or gains focus.
fun(focused: boolean)
smgf.gamepad
smgf.gamepad.get_axis
function smgf.gamepad.get_axis(player_index: SMGFPlayerIndex, axis: SMGFGamepadAxis)
-> axis_value: number
Returns the current state of a given axis (value goes from -1 to 1).
axis:
| "leftx"
| "lefty"
| "rightx"
| "righty"
| "lefttrigger"
| "righttrigger"
smgf.gamepad.get_name
function smgf.gamepad.get_name(player_index: SMGFPlayerIndex)
-> name: string
Returns the name of a gamepad.
smgf.gamepad.is_down
function smgf.gamepad.is_down(player_index: SMGFPlayerIndex, button_no: SMGFGamepadButton)
-> is_down: boolean
Returns whether a button is pressed for a given gamepad.
button_no:
| "a"
| "b"
| "x"
| "y"
| "back"
| "guide"
| "start"
| "leftstick"
| "rightstick"
| "leftshoulder"
| "rightshoulder"
| "dpup"
| "dpdown"
| "dpleft"
| "dpright"
| "misc1"
| "paddle1"
| "paddle2"
| "paddle3"
| "paddle4"
| "touchpad"
smgf.gamepad.is_open
function smgf.gamepad.is_open(player_index: SMGFPlayerIndex)
-> is_open: boolean
Returns whether a given gamepad is opened and available to use.
smgf.gamepad.rumble
function smgf.gamepad.rumble(player_index: SMGFPlayerIndex, duration_sec: number, lintensity: number, rintensity?: number)
-> result: number
Rumbles the given gamepad.
@param duration_sec
— The duration of the rumble in seconds
@param lintensity
— The left intensity (value between 0 and 1)
@param rintensity
— The right intensity (value between 0 and 1), defaults is the lintensity
@return result
— 0 if everything OK, -1 if rumble not supported for this gamepad, 1 if gamepad not found
smgf.gamepad_added
Callback, called when a gamepad has been detected. The "player_index" is a number between 1 and 4 to identify the player.
fun(player_index: SMGFPlayerIndex)
smgf.gamepad_axismotion
Callback, called when there has been an axis motion on a gamepad. The "player_index" is a number between 1 and 4 to identify the player. The "axis" parameter can either be "leftx", "lefty", "rightx", "righty", "lefttrigger" or "righttrigger". The "value" parameter is in the range [-1;1].
fun(player_index: SMGFPlayerIndex, axis: SMGFGamepadAxis, value: number)
smgf.gamepad_down
Callback, called when a button has been pressed on a gamepad. The "player_index" is a number between 1 and 4 to identify the player.
fun(player_index: SMGFPlayerIndex, button_no: SMGFGamepadButton)
smgf.gamepad_removed
Callback, called when a gamepad has been removed. The "player_index" is a number between 1 and 4 to identify the player.
fun(player_index: SMGFPlayerIndex)
smgf.gamepad_up
Callback, called when a button has been released on a gamepad. The "player_index" is a number between 1 and 4 to identify the player.
fun(player_index: SMGFPlayerIndex, button_no: SMGFGamepadButton)
smgf.graphics
smgf.graphics.clear
function smgf.graphics.clear(r: number, g: number, b: number, a?: number)
Clears the current target with a given color.
@param r
— Red component (0 - 255)
@param g
— Green component (0 - 255)
@param b
— Blue component (0 - 255)
@param a
— Alpha component (0 - 255)
smgf.graphics.draw
function smgf.graphics.draw(texture: SMGFTexture, x?: number, y?: number, scale_x?: number, scale_y?: number, rotation?: number, origin_x?: number, origin_y?: number, flip?: SMGFFlip)
Draws a texture at position (x, y)
, scaled to (scale_x, scale_y)
,
rotated of rotation
degrees around (origin_x, origin_y)
and optionally flipped ("none", "horizontal" or "vertical"). To only display
a portion of the texture, pass a SMGFQuad
(table with four numbers) as second parameter.
@param texture
— The texture to draw
@param x
— The position to draw to (X), defaults to 0
@param y
— The position to draw to (Y), defaults to 0
@param scale_x
— Scale value (X), defaults to 1
@param scale_y
— Scale value (Y), defaults to 1
@param rotation
— The rotation in degrees, defaults to 0
@param origin_x
— The origin of the rotation (X), defaults to 0
@param origin_y
— The origin of the rotation (Y), defaults to 0
@param flip
— To flip the texture when drawing, defaults to "none"
flip:
| "none"
| "horizontal"
| "vertical"
smgf.graphics.draw_line
function smgf.graphics.draw_line(x1: number, y1: number, x2: number, y2: number)
Draws a line from (x1, y1)
to (x2, y2)
.
@param x1
— The position to draw the line from (X)
@param y1
— The position to draw the line from (Y)
@param x2
— The position to draw the line to (X)
@param y2
— The position to draw the line to (Y)
smgf.graphics.draw_point
function smgf.graphics.draw_point(x: number, y: number)
Draws a point at (x, y)
.
@param x
— The position to draw to (X)
@param y
— The position to draw to (Y)
smgf.graphics.draw_rect
function smgf.graphics.draw_rect(x: number, y: number, width: number, height: number)
Draws a rectangle at (x, y)
of size (width, height)
.
@param x
— The position to draw to (X)
@param y
— The position to draw to (Y)
@param width
— The width of the rectangle
@param height
— The height of the rectangle
smgf.graphics.draw_rectfill
function smgf.graphics.draw_rectfill(x: number, y: number, width: number, height: number)
Draws a filled rectangle at (x, y)
of size (width, height)
.
@param x
— The position to draw to (X)
@param y
— The position to draw to (Y)
@param width
— The width of the rectangle
@param height
— The height of the rectangle
smgf.graphics.get_blend_mode
function smgf.graphics.get_blend_mode()
-> mode: SMGFBlendMode
Returns the blend mode used for drawing operations (points, lines, rects). By default, the blend mode is set to "blend".
-- Blend mode.
mode:
| "none"
| "blend"
| "add"
| "mod"
| "mul"
See: SMGFTexture.get_blend_mode
smgf.graphics.get_color
function smgf.graphics.get_color()
-> r: number
2. g: number
3. b: number
4. a: number
Returns the current color.
@return r
— Red component (0 - 255)
@return g
— Green component (0 - 255)
@return b
— Blue component (0 - 255)
@return a
— Alpha component (0 - 255)
smgf.graphics.get_point
function smgf.graphics.get_point(x: number, y: number)
-> r: number
2. g: number
3. b: number
Returns the color a single point on texture (or screen). WARNING: for testing uses only, do not use this function.
@return r
— Red component (0 - 255)
@return g
— Green component (0 - 255)
@return b
— Blue component (0 - 255)
smgf.graphics.get_target
function smgf.graphics.get_target()
-> texture: SMGFTexture|nil
Returns the current target, which can either be a texture or "nil" (the screen).
@return texture
— Current target
smgf.graphics.get_translation
function smgf.graphics.get_translation()
-> x: number
2. y: number
Returns the current drawing origin.
smgf.graphics.new
function smgf.graphics.new(filename: string)
-> SMGFTexture
Loads an image into memory, and returns a texture. Note that smgf only supports PNG files by default (can be configured at build)
@param filename
— File path
smgf.graphics.new
function smgf.graphics.new(width: number, height: number)
-> SMGFTexture
Creates a new empty texture which can be drawn upon.
@param width
— Width of texture to create
@param height
— Height of texture to create
See: smgf.graphics.set_target
smgf.graphics.pop_state
function smgf.graphics.pop_state()
Destroys the current graphic state and activates the previous one. If no previous state exists, smgf automatically creates a new "blank" state.
smgf.graphics.print
function smgf.graphics.print(x: number, y: number, color: number, text: string)
Draws text using an internal debug font. Meant as a quick way to display debug info on screen.
@param x
— The position to draw to (X)
@param y
— The position to draw to (Y)
@param color
— Expects a number between 0-15 (CGA 16-color palette). Pass 0x0F
to draw text in white with transparent background.
@param text
— The text to draw (encoded in ISO-8859-1)
smgf.graphics.push_state
function smgf.graphics.push_state()
Creates a new graphic state and activates it. Use "smgf.graphics.pop_state" to re-activate the previous state.
smgf.graphics.reset_state
function smgf.graphics.reset_state()
Resets the current graphic state (color, drawing origin, current target).
smgf.graphics.screenshot
function smgf.graphics.screenshot(filename: string)
Takes a screenshot of the screen and saves it as a BMP. Filename must end with ".bmp".
@param filename
— The filename (must end with ".bmp")
smgf.graphics.set_blend_mode
function smgf.graphics.set_blend_mode(mode?: SMGFBlendMode)
Sets the blend mode used for drawing of points, lines and rects. By default, the blend mode is set to "blend".
@param mode
— Defaults to "blend" if nil
-- Blend mode.
mode:
| "none"
| "blend"
| "add"
| "mod"
| "mul"
See: SMGFTexture.set_blend_mode
smgf.graphics.set_color
function smgf.graphics.set_color(r: number, g: number, b: number, a?: number)
Sets the current color.
@param r
— Red component (0 - 255)
@param g
— Green component (0 - 255)
@param b
— Blue component (0 - 255)
@param a
— Alpha component (0 - 255), defaults to 255
smgf.graphics.set_target
function smgf.graphics.set_target(texture: SMGFTexture|nil)
Sets the current target to a texture. All future draws will be executed on this texture. Pass "nil" to draw directly to the screen.
@param texture
— The texture to set as target or nil to draw directly to the screen
smgf.graphics.set_translation
function smgf.graphics.set_translation(x: number, y: number)
Sets the current drawing origin.
smgf.graphics.translate
function smgf.graphics.translate(x: number, y: number)
Adds "x" and "y" to the drawing origin: all future drawing operations will be translated.
smgf.init
Callback, called once at the start of the program.
fun()
smgf.io
smgf.io.delete
function smgf.io.delete(filename: string)
Deletes a file.
@param filename
— The filename to delete
smgf.io.exists
function smgf.io.exists(filename: string)
-> exists: boolean
Returns whether a file exists.
@param filename
— The filename to query
smgf.io.mkdir
function smgf.io.mkdir(dirname: string)
Creates a directory.
@param dirname
— The directory to create
smgf.io.open
function smgf.io.open(filename: string, mode: "a"|"r"|"w")
-> SMGFFile
Opens a file for use.
@param filename
— The filename to open
@param mode
— Whether to open the file in read (r), write (w) mode, or append (a) mode.
mode:
| "r"
| "w"
| "a"
smgf.io.type
function smgf.io.type(filename: string)
-> type: "directory"|"file"|"other"|"symlink"
Returns a file type.
@param filename
— The filename to query
@return type
— The file type
type:
| "file"
| "directory"
| "symlink"
| "other"
smgf.key_down
Callback, called when a keyboard key is pressed. The "mod" parameter is a table and represent the key modifiers currently pressed: "lshift", "rshift", "lctrl", "rctrl", "lalt", "ralt", "lgui" (Windows key or Command ⌘ on Mac), "rgui", "num", "caps", "mode".
fun(key: string, mod: SMGFKeyMod[])
smgf.key_up
Callback, called when a keyboard key is released. The "mod" parameter is a table and represent the key modifiers currently pressed: "lshift", "rshift", "lctrl", "rctrl", "lalt", "ralt", "lgui" (Windows key or Command ⌘ on Mac), "rgui", "num", "caps", "mode".
fun(key: string, mod: SMGFKeyMod[])
smgf.keyboard
smgf.keyboard.get_textinput
function smgf.keyboard.get_textinput()
-> enabled: boolean
Returns whether Unicode text input events are enabled. This is disabled by default.
smgf.keyboard.is_down
function smgf.keyboard.is_down(key: string)
-> is_down: boolean
Returns whether a key is down (pressed).
smgf.keyboard.is_up
function smgf.keyboard.is_up(key: string)
-> is_up: boolean
Returns whether a key is up (not pressed).
smgf.keyboard.set_textinput
function smgf.keyboard.set_textinput(enabled: boolean)
Enables or disables Unicode text input events. This function controls
whether smgf.text_input
callbacks are sent or not. This is
disabled by default.
smgf.mouse
smgf.mouse.get_pos
function smgf.mouse.get_pos()
-> x: number
2. y: number
Returns the mouse position (2 values). Note that the coordinates start from the top left corner of the screen.
smgf.mouse.get_x
function smgf.mouse.get_x()
-> x: number
Returns the mouse position in X. Note that the coordinates start from the top left corner of the screen.
smgf.mouse.get_y
function smgf.mouse.get_y()
-> y: number
Returns the mouse position in Y. Note that the coordinates start from the top left corner of the screen.
smgf.mouse.is_down
function smgf.mouse.is_down(button_no: number)
-> is_down: boolean
Returns whether a key is pressed. Expects a number: 1 is left button, 2 is middle button, 3 is right button.
smgf.mouse_down
Callback, called on mouse press. The button number can be either 1 (left button), 2 (middle button) or 3 (right button).
fun(x: number, y: number, button_no: number)
smgf.mouse_moved
Callback, called on mouse movement. The first two arguments represent the current mouse position, and the two last represent the actual mouse movement.
fun(x: number, y: number, xdiff: number, ydiff: number)
smgf.mouse_up
Callback, called on mouse release. The button number can be either 1 (left button), 2 (middle button) or 3 (right button).
fun(x: number, y: number, button_no: number)
smgf.mouse_wheel
Callback, called on mouse wheel movement.
fun(x: number, y: number)
smgf.system
smgf.system.get_clipboard
function smgf.system.get_clipboard()
-> clipboard: string
Returns the value of the user clipboard.
@return clipboard
— The contents of clipboard
smgf.system.get_cursor_visible
function smgf.system.get_cursor_visible()
-> visible: boolean
Returns whether the cursor is visible when mouse hovers over game window.
@return visible
— Whether the cursor is visible
smgf.system.get_dimensions
function smgf.system.get_dimensions()
-> width: number
2. height: number
Returns the dimensions of the screen.
@return width
— The width of the screen
@return height
— The height of the screen
smgf.system.get_dt
function smgf.system.get_dt()
-> dt: number
Returns the delta time sent to the most recent call of smgf.update
.
@return dt
— Delta time in seconds
smgf.system.get_fps
function smgf.system.get_fps()
-> fps: number
Returns the FPS (frames per second) limit of the game.
@return fps
— FPS limit of the game (0 if FPS limiting is disabled)
smgf.system.get_fullscreen
function smgf.system.get_fullscreen()
-> fullscreen: boolean
Returns whether the full screen mode is enabled.
@return fullscreen
— Delta Whether fullscreen is enabled or not
smgf.system.get_height
function smgf.system.get_height()
-> height: number
Returns the height of the screen.
@return height
— The height of the screen
smgf.system.get_identity
function smgf.system.get_identity()
-> organisation: string
2. application: string
Returns the identity for the game.
@return organisation
— The name of the organisation
@return application
— The name of the application
smgf.system.get_platform
function smgf.system.get_platform()
-> platform: string
Returns the platform on which the game is running on: "Linux", "Mac OS X", "Windows" or "Emscripten".
@return platform
— The platform on which the game is running on
smgf.system.get_preferred_locales
function smgf.system.get_preferred_locales()
-> locales: string[]|nil
Returns a list of user preferred locales (or nil if it is impossible to retrieve). Only languages codes (ISO-639) are returned.
smgf.system.get_version
function smgf.system.get_version()
-> smgf: string
Returns smgf version (in form "1.0.0")
@return smgf
— version
smgf.system.get_width
function smgf.system.get_width()
-> width: number
Returns the width of the screen.
@return width
— The width of the screen
smgf.system.get_window_title
function smgf.system.get_window_title()
-> title: string
Returns the window's title.
@return title
— The window title
smgf.system.get_write_dir
function smgf.system.get_write_dir()
-> path: string|nil
Returns the path to the writeable directory, or nil if the identity of the game has not been set.
@return path
— The path to the writeable directory
See: smgf.system.set_identity
smgf.system.get_zoom
function smgf.system.get_zoom()
-> zoom: number
Returns the zoom of the game.
@return zoom
— Zoom of the game
smgf.system.iconv
function smgf.system.iconv(to: string, from: string, str: string)
-> converted: string
Converts a string between encodings.
@param to
— The source encoding
@param from
— The target encoding
@param str
— The string to convert
@return converted
— The converted string
smgf.system.open_url
function smgf.system.open_url(url: string)
Opens a URL. Can be either a local file path or a HTTPS URL.
@param url
— The URL to open
smgf.system.quit
function smgf.system.quit()
Exits smgf gracefully.
smgf.system.set_clipboard
function smgf.system.set_clipboard(contents: string)
Sets the user clipboard to some value.
@param contents
— The string to put in clipboard
smgf.system.set_cursor_visible
function smgf.system.set_cursor_visible(visible: boolean)
Toggles cursor visibility when mouse hovers over game window.
@param visible
— Whether the cursor should be visible
smgf.system.set_dimensions
function smgf.system.set_dimensions(width: number, height: number)
Sets the dimensions of the screen.
@param width
— The width of the screen
@param height
— The height of the screen
smgf.system.set_fps
function smgf.system.set_fps(fps: number|nil)
Sets the FPS (frames per second) limit.
@param fps
— The fps of the screen (or nil to reset limit)
smgf.system.set_fullscreen
function smgf.system.set_fullscreen(fullscreen: boolean)
Enables or disables the full screen mode.
@param fullscreen
— Whether to enable fullscreen or not
smgf.system.set_identity
function smgf.system.set_identity(organisation: string, application: string)
Sets the identity for the game. Expects two strings: the name of your
organisation and your application name.
These two strings are used to open a writeable directory on the user
computer. For maximum compatibility, try to avoid special characters.
It is recommended to set identity using conf.lua
file instead of calling
this function.
@param organisation
— The name of your organisation
@param application
— The name of your application
smgf.system.set_window_title
function smgf.system.set_window_title(title: string)
Sets the window title.
@param title
— The window title
smgf.system.set_zoom
function smgf.system.set_zoom(zoom: number|nil)
Sets the zoom.
@param zoom
— The zoom of the screen (or nil to reset zoom)
smgf.system.show_message
function smgf.system.show_message(title: string, message: string, level?: "error"|"info"|"warning")
Opens a dialog to the user, with a given title and message.
@param level
— Defaults to "info"
level:
| "info"
| "warning"
| "error"
smgf.system.sleep
function smgf.system.sleep(seconds: number)
Waits for a given time (in seconds) before returning to the program.
@param seconds
— Sleep time in seconds
smgf.targets_reset
Callback, called on SDL_RENDER_TARGETS_RESET event.
fun()
smgf.text_input
Callback, called on text input. Needs to be enabled first with "smgf.keyboard.set_textinput".
fun(text: string)
smgf.update
Callback, called every frame before smgf.draw
. "dt" represents the seconds since the last call to smgf.update
. All game updates should be done there.
fun(dt: number)
SMGFBlendMode
-- Blend mode.
SMGFBlendMode:
| "none"
| "blend"
| "add"
| "mod"
| "mul"
"add"|"blend"|"mod"|"mul"|"none"
SMGFFile
A file that can be read and/or written to.
SMGFFile.close
(method) SMGFFile:close()
Closes a file. Beware that the file object will not be usable after calling this function.
SMGFFile.flush
(method) SMGFFile:flush()
-> offset: number
Flushs a buffered file.
SMGFFile.read
(method) SMGFFile:read(mode: "all"|"line")
-> string
Reads from a file. Pass "all" to read all file at once, "line" to read the current line, or a number to read an arbitrary number of bytes from file. Make sure the file was opened with "r" flag or it will trigger an error.
@param mode
— Whether to read the current line in file, or the whole file.
mode:
| "all"
| "line"
SMGFFile.rewind
(method) SMGFFile:rewind()
Sets the file cursor position to the beginning of file.
SMGFFile.seek
(method) SMGFFile:seek(offset: number, mode?: "cur"|"end"|"set")
-> final_offset: number
Sets the file cursor position.
@param offset
— The offset in bytes
@param mode
— cur
= seek relative to current read point, set
= seek from the beginning of data, end
= seek relative to the end of data, defaults to cur
@return final_offset
— The offset after operation
mode:
| "set"
| "cur"
| "end"
SMGFFile.size
(method) SMGFFile:size()
-> size: number
Returns file size in bytes.
@return size
— Size in bytes
SMGFFile.tell
(method) SMGFFile:tell()
-> offset: number
Returns current cursor position.
SMGFFile.write
(method) SMGFFile:write(data: string)
Writes a string to a file. Make sure the file was opened with "w" flag or it will trigger an error.
@param data
— The data to write to file
SMGFFlip
SMGFFlip:
| "none"
| "horizontal"
| "vertical"
"horizontal"|"none"|"vertical"
SMGFGamepadAxis
SMGFGamepadAxis:
| "leftx"
| "lefty"
| "rightx"
| "righty"
| "lefttrigger"
| "righttrigger"
"lefttrigger"|"leftx"|"lefty"|"righttrigger"|"rightx"|"righty"
SMGFGamepadButton
SMGFGamepadButton:
| "a"
| "b"
| "x"
| "y"
| "back"
| "guide"
| "start"
| "leftstick"
| "rightstick"
| "leftshoulder"
| "rightshoulder"
| "dpup"
| "dpdown"
| "dpleft"
| "dpright"
| "misc1"
| "paddle1"
| "paddle2"
| "paddle3"
| "paddle4"
| "touchpad"
"a"|"b"|"back"|"dpdown"|"dpleft"|"dpright"|"dpup"|"guide"|"leftshoulder"|"leftstick"|"misc1"|"paddle1"|"paddle2"|"paddle3"|"paddle4"|"rightshoulder"|"rightstick"|"start"|"touchpad"|"x"...(+1)
SMGFKeyMod
-- A key modifier (such as "shift", "control", "command", etc.)
SMGFKeyMod:
| "lshift"
| "rshift"
| "lctrl"
| "rctrl"
| "lalt"
| "ralt"
| "lgui"
| "rgui"
| "num"
| "caps"
| "mode"
"caps"|"lalt"|"lctrl"|"lgui"|"lshift"|"mode"|"num"|"ralt"|"rctrl"|"rgui"|"rshift"
SMGFPlayerIndex
A number between 1 and 4 to identify the player. The first gamepad plugged will be "1", the second "2", the third "3" etc.
number
SMGFQuad
A quadrilateral, used to work on a portion of a texture. Requires 4 elements: x, y, width and height.
number[]
SMGFSound
A sound that can be played.
SMGFSound.clone
(method) SMGFSound:clone()
-> clone: SMGFSound
Creates a copy of a SMGFSound
.
SMGFSound.get_duration
(method) SMGFSound:get_duration()
-> Duration: number
Returns the duration of a sound in milliseconds.
@return Duration
— in milliseconds
SMGFSound.get_gain
(method) SMGFSound:get_gain()
-> gain: number
Returns the gain ("volume") of a sound, which is a number from "0" (silence) to "2" (200%).
SMGFSound.get_loop
(method) SMGFSound:get_loop()
-> looped: boolean
Returns whether a sound is looped or not.
SMGFSound.get_pan
(method) SMGFSound:get_pan()
-> pan: number
Returns the panning of a sound, which is a number from "-1" (left) to "1" (right).
SMGFSound.is_playing
(method) SMGFSound:is_playing()
-> playing: boolean
Returns whether a sound is playing or not.
SMGFSound.is_predecoded
(method) SMGFSound:is_predecoded()
-> predecoded: boolean
Returns whether a sound is predecoded or not.
SMGFSound.pause
(method) SMGFSound:pause()
Pauses the playback of a sound.
SMGFSound.play
(method) SMGFSound:play()
Starts playing a sound.
SMGFSound.rewind
(method) SMGFSound:rewind()
Rewinds a sound.
SMGFSound.seek
(method) SMGFSound:seek(ms: number)
Modifies the playback position of a sound.
@param ms
— The position in milliseconds
SMGFSound.set_gain
(method) SMGFSound:set_gain(gain: number)
Modifies the gain ("volume") of a sound. Expects a number from "0" (silence) to "2" (200%). Default value is "0" (100%).
SMGFSound.set_loop
(method) SMGFSound:set_loop(looped: boolean)
Sets whether a sound should be looped or not.
SMGFSound.set_pan
(method) SMGFSound:set_pan(pan: number)
Modifies the panning of a sound. Expects a number from "-1" (left) to "1" (right). Default value is "0" (center).
SMGFTexture
A texture that can be draw on screen (or on an offscreen target)
SMGFTexture.draw
(method) SMGFTexture:draw(x?: number, y?: number, scale_x?: number, scale_y?: number, rotation?: number, origin_x?: number, origin_y?: number, flip?: SMGFFlip)
Draws the texture.
@param x
— The position to draw to (X), defaults to 0
@param y
— The position to draw to (Y), defaults to 0
@param scale_x
— Scale value (X), defaults to 1
@param scale_y
— Scale value (Y), defaults to 1
@param rotation
— The rotation in degrees, defaults to 0
@param origin_x
— The origin of the rotation (X), defaults to 0
@param origin_y
— The origin of the rotation (Y), defaults to 0
@param flip
— To flip the texture when drawing, defaults to "none"
flip:
| "none"
| "horizontal"
| "vertical"
See: smgf.graphics.draw For the list of all parameters
SMGFTexture.get_blend_mode
(method) SMGFTexture:get_blend_mode()
-> mode: SMGFBlendMode
Returns the blend mode used when drawing the texture ("blend" by default).
-- Blend mode.
mode:
| "none"
| "blend"
| "add"
| "mod"
| "mul"
SMGFTexture.get_dimensions
(method) SMGFTexture:get_dimensions()
-> width: number
2. height: number
Returns the dimensions (width and height) of a texture.
@return width
— Width of texture
@return height
— Height of texture
SMGFTexture.get_height
(method) SMGFTexture:get_height()
-> height: number
Returns the height of a texture.
@return height
— Height of texture
SMGFTexture.get_width
(method) SMGFTexture:get_width()
-> width: number
Returns the width of a texture.
@return width
— Width of texture
SMGFTexture.save
(method) SMGFTexture:save(filename: string)
Saves the texture as a BMP file. Filename must end with ".bmp".
@param filename
— The filename (must end with ".bmp")
SMGFTexture.set_blend_mode
(method) SMGFTexture:set_blend_mode(mode?: SMGFBlendMode)
Sets the blend mode used when drawing the texture.
@param mode
— Defaults to "blend" if nil
-- Blend mode.
mode:
| "none"
| "blend"
| "add"
| "mod"
| "mul"