SMILE 2.0Learn & build
Language guide

LOOK IT UP

Built-in reference

A searchable toolbox for the moments when you know what you want to do, but need the exact name and arguments.

Read a signature

Text_Length(text As Text) As Number means: give the function a Text value, and receive a whole Number. Parentheses hold arguments. The final As names the result type. Use a returned value in an assignment, comparison, or expression.

Dim Name As Text
Dim Letters As Number
Name = "Nova"
Letters = Text_Length(Name)
Print Letters

55 runtime functions, no Import needed. This list matches the compiler function catalog. Entries marked Game Window need a graphical program. Built-in calls use positional arguments; named arguments belong to user/library routines. Imported packages have their own APIs.

Find a function

55 functions

Math

Abs

Abs(value As Number) As Number

Distance from zero. Abs(-8) is 8. Also accepts a Double and returns Double; keep argument types consistent.

Min

Min(first As Number, second As Number) As Number

The smaller value. Also accepts two Doubles. Useful for limiting a player's position.

Max

Max(first As Number, second As Number) As Number

The larger value. Also accepts two Doubles. Max(0, Health - Damage) keeps health from becoming negative.

ToDouble

ToDouble(value As Number) As Double

Explicitly converts a whole Number to Double. Very large integers can lose precision in binary64.

ToNumber

ToNumber(value As Double) As Number

Truncates toward zero: ToNumber(7.9) is 7. Out-of-range conversion fails.

Clamp

Clamp(value As Double, minimum As Double, maximum As Double) As Double

Keeps a Double between its bounds. Use Clamp(Health, 0.0, 100.0) for Double values; minimum must not exceed maximum.

Sqrt

Sqrt(value As Double) As Double

Square root. Sqrt(25.0) is 5.0. Negative input fails.

Sin

Sin(value As Double) As Double

Sine of an angle in radians. Use it for waves, bobbing objects, and circular motion.

Cos

Cos(value As Double) As Double

Cosine of an angle in radians. Pair with Sin for circular motion.

Atan2

Atan2(y As Double, x As Double) As Double

Direction angle in radians from a pair of coordinates.

Floor

Floor(value As Double) As Double

Rounds down: Floor(-1.2) is -2.0. The result stays Double.

Ceiling

Ceiling(value As Double) As Double

Rounds up: Ceiling(1.2) is 2.0. The result stays Double.

Truncate

Truncate(value As Double) As Double

Drops the fractional part toward zero. The result stays Double.

Round

Round(value As Double) As Double

Rounds to the nearest whole value, with exact halves going to the even value: Round(2.5) is 2.0 and Round(3.5) is 4.0.

Text

Text_Length

Text_Length(text As Text) As Number

Counts Unicode scalar values. This is character-oriented text processing, not a UTF-8 byte count.

Text_Code_At

Text_Code_At(text As Text, index As Number) As Number

Returns a Unicode scalar at zero-based index, or -1 if the index is outside the text.

Text_Slice

Text_Slice(text As Text, start As Number, count As Number) As Text

Takes a Unicode scalar slice. A negative start, nonpositive count, or start beyond the end returns empty text; a long count clamps to the available text.

Text_From_Double

Text_From_Double(value As Double) As Text

Converts a finite Double to culture-independent round-trip text, such as 2.5.

Text_To_Double

Text_To_Double(value As Text) As Double

Parses a finite decimal/exponent value using a decimal point. Malformed or nonfinite text fails; use with controlled input.

Timing and windows

Timer

Timer() As Number

Returns elapsed milliseconds from the runtime timer. Compare two readings to measure elapsed time.

Game_Closed Game Window

Game_Closed() As Boolean

True when the game window has closed. Use it as a game-loop exit condition.

Window_Width Game Window

Window_Width() As Number

Returns the logical canvas width.

Window_Height Game Window

Window_Height() As Number

Returns the logical canvas height.

Window_Title Game Window

Window_Title(text As Text) As Boolean

Changes the native window title or Web document title.

Window_Activate Game Window

Window_Activate() As Boolean

Restores/requests focus for a native game window and reports success. Web currently returns False.

Window_Loading Game Window

Window_Loading() As Boolean

Shows the shared loading presentation again. Load a scene after success; the next Show Screen completes the transition after the minimum display time.

Window_DeferClose Game Window

Window_DeferClose(defer As Boolean) As Boolean

Enables or disables deferred closing. Native apps can offer save/discard/cancel. Web requests the browser's own unsaved-work prompt, subject to browser policy.

Window_CloseRequested Game Window

Window_CloseRequested() As Boolean

Consumes a deferred native close request once. Web returns False because tab-close confirmation belongs to the browser.

Keyboard

Key_Held Game Window

Key_Held(key As Number) As Boolean

Reads the current live held state. Use with KEY_LEFT, KEY_RIGHT, or another named key for continuous movement.

Key_Event_Held Game Window

Key_Event_Held(key As Number) As Boolean

Reads which named keys were held when the most recent queued Get Key event occurred. Useful for a quick Control+Arrow shortcut.

Pointer

Pointer_X Game Window

Pointer_X() As Number

Logical canvas x coordinate of the latest pointer position.

Pointer_Y Game Window

Pointer_Y() As Number

Logical canvas y coordinate of the latest pointer position.

Pointer_Delta_X Game Window

Pointer_Delta_X() As Number

Accumulated x movement in this frame. Show Screen clears frame deltas.

Pointer_Delta_Y Game Window

Pointer_Delta_Y() As Number

Accumulated y movement in this frame. Show Screen clears frame deltas.

Pointer_Wheel_Delta Game Window

Pointer_Wheel_Delta() As Number

Wheel movement accumulated during this frame, cleared by Show Screen.

Pointer_Wheel_Remainder Game Window

Pointer_Wheel_Remainder() As Number

Native raw wheel units retained below one 120-unit step; Web currently returns zero.

Pointer_Inside Game Window

Pointer_Inside() As Boolean

Whether the latest pointer position is inside the logical game canvas.

Pointer_Held Game Window

Pointer_Held(button As Number) As Boolean

True while a contact owns the chosen button role; held state remains across frames.

Pointer_Pressed Game Window

Pointer_Pressed(button As Number) As Boolean

True if this button was pressed during the current frame; read before Show Screen.

Pointer_Released Game Window

Pointer_Released(button As Number) As Boolean

True if this button was released during the current frame; read before Show Screen.

Images and drawing

Rgb

Rgb(red As Number, green As Number, blue As Number) As Number

Builds a color from red, green, and blue components. Use values from 0 to 255.

Image_Width

Image_Width(image As Image) As Number

Original pixel width of a loaded image.

Image_Height

Image_Height(image As Image) As Number

Original pixel height of a loaded image.

Image_Loaded

Image_Loaded(image As Image) As Boolean

Checks whether an Image holds a loaded resource.

Text_Width Game Window

Text_Width(text As Text, size As Number) As Number

Measures text using the target's drawing engine; use it to lay out a label.

Text_Height Game Window

Text_Height(text As Text, size As Number) As Number

Measures text height. Positive text sizes give a positive height even for empty text.

File transfer

File_Export

File_Export(fileName As Text, contents As Text) As Boolean

Requests a user-chosen UTF-8 file export. Native uses a file dialog; Web requests a download. Success on Web means the request was accepted, not proof the file reached disk.

File_Import

File_Import() As Text

Requests user-chosen UTF-8 text. Empty, canceled, and unavailable results all return empty text; trigger it from an explicit user action.

File_Reveal

File_Reveal(text As Text) As Boolean

Native helper to reveal an existing absolute Windows drive path in the file manager. Returns False where unavailable; it is not a portable game-asset loader.

Renderer bridge

Renderer3D Game Window

Renderer3D(command As Number, a As Number, b As Number, c As Number, d As Number, e As Number, f As Number, g As Number, h As Number, i As Number, j As Number) As Number

Low-level renderer command bridge used by Smile.Simple3D. Learn Graphics3D, Precision3D, and ArenaViewport3D instead of inventing command numbers.

Renderer3DImage Game Window

Renderer3DImage(command As Number, image As Image, a As Number, b As Number, c As Number, d As Number, e As Number, f As Number, g As Number, h As Number) As Number

Image-to-renderer bridge used by the library's texture/material operations.

Renderer3DText Game Window

Renderer3DText(command As Number, text As Text, a As Number, b As Number, c As Number, d As Number, e As Number, f As Number, g As Number, h As Number) As Number

Text-to-renderer bridge used by the library's resource operations.

Renderer3DTextValue Game Window

Renderer3DTextValue(command As Number, a As Number, b As Number, c As Number, d As Number, e As Number, f As Number, g As Number, h As Number, i As Number) As Text

Renderer query bridge with a Text result; use the named library wrapper.

Renderer3DDouble Game Window

Renderer3DDouble(command As Number, resource As Number, a As Double, b As Double, c As Double, d As Double, e As Double, f As Double, g As Double, h As Double, i As Double, j As Double, k As Double, l As Double) As Number

Typed precision bridge. Command/resource are Number; the twelve value slots are Double. High-level precision modules own scene state.

Renderer3DDoubleValue Game Window

Renderer3DDoubleValue(command As Number, resource As Number, index As Number, component As Number) As Double

Queries a Double value from the renderer through a named library wrapper.

Constants you can use immediately

A constant is a named value that stays the same. Prefer a name such as KEY_ESCAPE over its numeric code.

FamilyNames and meaning
KeyboardKEY_NONE, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER, KEY_ESCAPE, KEY_SPACE, KEY_TAB, KEY_CONTROL, KEY_BACKTICK, KEY_PLUS, KEY_MINUS, KEY_1 through KEY_4, KEY_OTHER.
Named letter keysKEY_W, KEY_A, KEY_S, KEY_D, KEY_O, KEY_F, KEY_G, KEY_R, KEY_P, KEY_B, KEY_X, KEY_Y, KEY_Z, KEY_E, KEY_C. Other letters do not automatically have a KEY_ constant. KEY_C, KEY_PLUS, and KEY_MINUS currently have native support; their Web adoption is not claimed.
Virtual controllerKEY_PAD_A, KEY_PAD_B, KEY_PAD_X, KEY_PAD_Y are distinct Web controller buttons; physical keyboard letters do not produce these values.
Pointer buttonsPOINTER_PRIMARY, POINTER_SECONDARY, POINTER_MIDDLE.
ColorsBLACK, WHITE, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, ORANGE, GRAY; also DARK_RED, DARK_GREEN, DARK_BLUE, DARK_GRAY, and matching LIGHT_ variants.
LimitsSOUND_CHANNEL_COUNT = 16. DATA_BLOCK_MAX_BYTES = 1048576 (1 MiB).
Persistence resultsDATA_STATUS_OK, DATA_STATUS_MISSING, DATA_STATUS_RECOVERED, DATA_STATUS_INVALID, DATA_STATUS_UNAVAILABLE, DATA_STATUS_CORRUPT, DATA_STATUS_TOO_LARGE.
Legacy key aliasesNONE, W, A, S, D, UP, DOWN, LEFT, RIGHT remain available. New examples use the clearer KEY_ names.

Functions versus commands

Rgb(30, 180, 255) produces a value. Fill Circle 100, 80, 20, CYAN performs an action. Actions such as drawing, loading, playing audio, and saving use statement syntax, covered with examples in Graphics, input & sound. Arena and elemental effects shows how higher-level modules compose these building blocks.

Try a tiny experiment

Dim Wave As Double
Dim PixelY As Number
Wave = Sin(1.0) * 40.0
PixelY = ToNumber(Wave)
Print PixelY
Print Text_Slice("Dragon", 0, 4)

The second printed line is Drag. Try a start index of 2 and a count of 3. For the wave, use Double literals such as 1.0; SMILE does not silently mix Number and Double.

Sources & version notes

Checked against the local SMILE 2.0 source on September 25, 2026. Examples target the native Windows toolchain unless stated otherwise. The linked repository may continue to evolve.