SMILE 2.0Learn & build
Language guide

BUILD ON WHAT EXISTS

The library toolbox

Libraries give you tested building blocks. You bring the game idea, choose the rules, and connect the pieces.

Two kinds of toolbox

Runtime built-ins such as Rgb(), Key_Held(), and Draw Text are part of the language. Libraries are reusable SMILE code you add to a project and access with Import. A package can contain several modules; each module has a focused job.

The current compiler identifies Smile.Game, Smile.UI, and Smile.RPG as built-in libraries. The same repository also maintains the 3D and teaching packages below. They still need an explicit project or package reference.

Add a library in two steps

  1. In Visual Studio, use your project's References → Add SMILE 2.0 Library Reference… to select a .smilelibproj project or a built .smilelib package.
  2. Import the module you want in each source file that uses it. The alias after As is the short name you write in code.
Option Explicit
Import Smile.Game.Collision2D As Collision

Print Collision.CellsOverlap(3, 4, 3, 4)

This prints True: both positions occupy the same cell. Import names a module; it does not download a package or add a missing reference. Library dependencies must also be supplied at the required version.

Which shape of API? A Type such as CardinalMover is a copied value. A Class such as Menu is a shared object created with New. Some libraries return a Number handle, an ID for a bounded resource. Check creation results and release resources with the matching cleanup call.

The package map

Versions below are read from the current library project files. Start with the first three rows for 2D games; move into Simple3D when you are comfortable with the game loop.

PackageWhat it helps you buildModules / reference
Smile.Game
2.0.0
Built-in library
Movement, sprite timing, tile maps, cameras, and collision.Core, Animation, TileMap, Camera2D, Collision2D.
Read the complete package reference
Smile.UI
2.0.0
Built-in library
Buttons, panels, styled text, bitmap fonts, menus, and dialogue.Core, Controls, Window, BitmapFont, Text, Menu, Dialogue.
Read the complete package reference
Smile.RPG
1.3.0
Built-in library
Characters, parties, inventory, equipment, abilities, shops, saves, world state, encounters, and turn-based battle rules.Core, Characters, Party, Inventory, Equipment, Abilities, Shops, SaveGames, World, Story, Encounters, BattleEffects, BattleCore, BattleStrategy, BattleView.
Read the complete package reference
Smile.Simple3D
2.0.0
3D package
3D meshes, materials, animation, cameras, shared arenas, and scene effects; also includes the earlier teaching wireframe layer.Graphics3D, Precision3D, Scene3D, Character3D, ArenaViewport3D, FireEmitter3D, WaterVfx3D, EarthVfx3D and more.
Read the complete package reference
Smile.Battle3D
1.2.1
Advanced package
Turns RPG battle presentation cues into timed 3D actor, camera, effect, and sound requests. Combat rules stay in RPG.Core, Actor, Articulation, Presentation, Camera, Effects.
Read the complete package reference
Smile.BattleTime
1.0.0
Advanced package
Adds deterministic active-time battle gauges to the RPG round engine. Active and Wait modes control when gauges advance.Smile.RPG.BattleTime (the exported module name differs from the package name).
Read the complete package reference
Smile.Math.Extras
1.0.0
Teaching/proof package
A small library example for whole-number Clamp and IsBetween.Smile.Math.Extras.
Read the complete package reference
Smile.Text.Extras
1.0.0
Teaching/proof package
Practises typed Text arguments, joining text, and ByRef replacement.Smile.Text.Extras.
Read the complete package reference
Smile.Data.Models
1.0.0
Teaching/proof package
Practises nested Actor records, deep copies, movement, and damage.Smile.Data.Models.
Read the complete package reference

Smile.Game: move one tile smoothly

CardinalMover separates the hero's logical cell from its animated pixel position. The destination becomes the real cell only when the move completes. Your game checks walls or occupied cells before starting a move.

Option Explicit

Import Smile.Game.Core As GCore
Import Smile.Game.Camera2D As Cameras
Import Smile.Game.Collision2D As Collision

Dim Hero As GCore.CardinalMover
Dim View As Cameras.CameraState
Dim Accepted As Boolean
Dim Arrived As Boolean
Dim StepIndex As Number

Call Hero.Place(2, 3, GCore.CardinalDirection.Right)
Accepted = View.Configure(320, 180, 1280, 720)

If Not Collision.OutsideMap(3, 3, 40, 22) Then
    Accepted = Hero.BeginMove(GCore.CardinalDirection.Right, 8)
End If

For StepIndex = 1 To 8
    Arrived = Hero.UpdateMove(1)
    Call View.Follow(Hero.VisualX(32), Hero.VisualY(32))
    Print Hero.VisualX(32)
End For

Print "Arrived: "; Arrived
Print "Cell: "; Hero.CellX; ", "; Hero.CellY
End Program

Download the movement example. Add the Smile.Game reference before building. Its printed X positions move from cell 2 toward cell 3; after eight steps, Arrived is True and the cell is 3, 3.

MemberUse it for
Hero.BeginMove(Direction, Duration) As BooleanTry to begin one cardinal move; duration is a positive number of steps.
Hero.UpdateMove(Steps) As BooleanAdvance a move; True means it completed this update.
Hero.VisualX(CellWidth) As Number, VisualY(CellHeight)Read an interpolated world position for drawing.
View.Configure(ViewWidth, ViewHeight, WorldWidth, WorldHeight) As BooleanSet the view and world dimensions.
View.Follow(TargetX, TargetY), SmoothFollow(TargetX, TargetY, MaximumStep)Keep the camera inside the world. Draw at world position minus camera X/Y.
Collision.FootprintsOverlap(X1, Y1, W1, H1, X2, Y2, W2, H2) As BooleanCheck overlapping rectangular footprints.

Animation and tile maps

Smile.Game.Animation keeps frame timing; you still draw the selected source rectangle. It supports 64 definitions with up to 16 frames each. Smile.Game.TileMap loads the documented SMILE-MAP 1 format, stores up to four maps, and draws Ground, Detail, and Foreground layers.

Import Smile.Game.Animation As Animation

Dim Walk As Number
Dim Accepted As Boolean
Dim FrameIndex As Number

Walk = Animation.Create(6, True, 0, 0)
If Animation.IsValid(Walk) Then
    Accepted = Animation.AddFrame(Walk, 0, 0, 32, 32)
    Accepted = Animation.AddFrame(Walk, 32, 0, 32, 32)
    FrameIndex = Animation.CurrentFrame(Walk, 7)
    Print FrameIndex
    Call Animation.Destroy(Walk)
End If

Here each frame lasts six caller-supplied steps. Seven elapsed steps select the second frame. The animation module does not read the clock for you. TileMap loading is transactional: an invalid load does not expose half a map.

Smile.UI: give the player a button

The Controls module is the smallest starting point. It detects clicks and draws controls; your game owns the meaning of a click.

Option Explicit

Import Smile.UI.Controls As Controls

Dim Selected As Boolean
Dim Key As Number

Game Window "My First Library Button" Size 640 By 360

Do
    Get Key Key
    If Controls.Clicked(220, 140, 200, 64) Then
        Selected = Not Selected
    End If

    Clear Rgb(12, 18, 36)
    Call Controls.DrawButton(220, 140, 200, 64, "Click Me", Selected)
    Draw Text "A library handles the button. You choose its action." At 320, 245 Size 16 Color WHITE Centered
    Show Screen
    Wait 16 Milliseconds

Loop Until Game_Closed() Or Key = KEY_ESCAPE

End Program

Download the button example. Add a Smile.UI reference. Click the button to toggle its selected state; Escape exits.

Menus and dialogue are objects

For keyboard-driven menus, use Import Smile.UI.Menu As Menus. Construct New Menus.Menu(Style, X, Y, Width, Height), check its Valid property, add choices with AddItem(Label, UserValue), feed queued keys to Update(Key), and draw with Call Menu.Draw(). MenuNavigator is exported by that same Menu module and handles submenus.

Smile.UI.Dialogue provides the Dialogue class for paged, gradually revealed text. Styles are value Types in Smile.UI.Core; skins, fonts, images, and sounds belong to your application. Call Destroy() explicitly: dialogues and navigators first, then their menus, then owned graphics. Setting a Class variable to Nothing releases that reference; it does not replace the documented bounded-slot cleanup.

See exact Menu, MenuNavigator, Dialogue, text, and font signatures.

Smile.RPG: rules and saved progress

A state handle holds one RPG session. Define stable character/item IDs before using them and register definitions before loading a save. The package calculates rules and progress; your game supplies pictures, input, and audio.

Option Explicit

Import Smile.RPG.Core As RPG
Import Smile.RPG.Party As Party

Dim State As Number
Dim Accepted As Boolean

State = RPG.Create()
If RPG.IsValid(State) Then
    Accepted = Party.AddGold(State, 25)
    Print "Gold: "; Party.Gold(State)
    Accepted = Party.SpendGold(State, 10)
    Print "Purchase accepted: "; Accepted
    Print "Gold left: "; Party.Gold(State)
    Call RPG.Destroy(State)
End If
End Program

Download the gold example. It prints 25 gold, a successful purchase, and 15 gold left. Always check Boolean/result-code returns before showing a success message.

GoalStart here
Heroes and inventoryCharacters, Party, Inventory, Equipment, Abilities
Buy and sellShops; operations return RPG_RESULT_* codes
Exploration and questsWorld, Story flags/values, Encounters; your game owns quest policy and presentation
Turn-based battlesBattleCore, BattleEffects, BattleStrategy, BattleView
Save progressSaveGames.SaveGame(StateHandle, SaveSlot, SchemaVersion) and LoadGame(StateHandle, SaveSlot, ExpectedSchemaVersion)

Active battles are transient and are not serialized by SaveGames. Definitions and save-schema choices belong to your game.

Smile.Simple3D: step into an arena

Use Graphics3D for the introductory integer-world API, Precision3D for Double transforms, and ArenaViewport3D for the shared floor, grid, backdrop, and smooth camera controls. Character3D handles independent playback of shared character assets.

Create geometry once, update it each frame, open a 3D pass, draw, close that pass, then draw the ordinary 2D HUD and call Show Screen. Destroy owned resources when leaving the scene. True 3D requires a supported renderer; native GDI preserves the wireframe/2D fallback.

All 32 Simple3D modules

Core, FixedMath, Math3D, Mesh, Primitives, Renderer, Interaction, CharacterViewer, Graphics3D, Precision3D, PrecisionMath3D, PrecisionCamera3D, Scene3D, Character3D, NodeAim3D, Effects3D, AetherBlade3D, FireEmitter3D, LightningVfx3D, WaterVfx3D, EarthVfx3D, WaterFlow3D, WaterImpact3D, WaterStorm3D, CharacterGlow3D, LightPool3D, SceneVfx3D, Arena3D, ArenaCamera3D, ArenaBackdrop3D, ArenaViewport3D, StaticBackdrop3D.

Battle presentation and time

Smile.Battle3D bridges RPG battle cues to actors, articulation, camera shots, and effects. It references Smile.RPG and Smile.Simple3D. Smile.BattleTime references Smile.RPG and exports Smile.RPG.BattleTime: Begin(StateHandle, Mode, Speed), Advance(StateHandle, Ticks, PresentationBusy), and TryStartRound(StateHandle) return Boolean results. Speed ranges from 1 to 5. Active mode advances while presentation is busy; Wait mode freezes it.

These are extensions for an existing battle system. Build your first moving character or small 2D game before adding battle orchestration.

Small packages for learning imports

Package / exact examplesLesson
Math.Clamp(150, 0, 100)
Math.IsBetween(5, 1, 10)
Import Smile.Math.Extras As Math. Its whole-number Clamp returns 100. This qualified library call is different from the runtime Clamp(150.0, 0.0, 100.0) for Doubles.
TextTools.JoinFive("A", " ", "tiny", " ", "game")
Call TextTools.Replace(Label, "Ready")
Import Smile.Text.Extras As TextTools. JoinFive returns Text; Replace changes a Text variable passed ByRef.
Models.CreateActor("Nova", 2, 3, 10, 10)
Call Models.Move(Hero, 1, 0)
Import Smile.Data.Models As Models. CreateActor returns an Actor record; Move and Damage change it ByRef. CopyActor demonstrates value copying.

Choose your next lesson

Draw, move, play sound, and save a score using runtime commands, or open the 55-function built-in reference when you need an exact signature.

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.