Examples

49 small scenes that each show one part of the engine. Every example runs in the browser next to its source, and the same files are the engine's regression suite.

Scenes

Scene lifecycle, switching, layers and Y-sorting.

  1. Screenshot of the A minimal scene example

    A minimal scene

    The smallest scene: a background colour, an update counter and text drawn in draw().

  2. Screenshot of the Lifecycle hooks example

    Lifecycle hooks

    The order in which load, start and update run on a scene and its game objects, logged on screen.

  3. Screenshot of the Switching scenes example

    Switching scenes

    Registers a second scene at runtime and switches between the two with the action button.

  4. Screenshot of the Layers and Y-sorting example

    Layers and Y-sorting

    Ground, entities and ui layers; entities sort by their feet so a ghost passes behind, then in front of, a tree.

Game objects

Declarative rendering, movement, parents and children, mouse events.

  1. Screenshot of the Rectangles, borders and text example

    Rectangles, borders and text

    Declarative rendering: set fillColor, borderRadius, border, textColor and font on a GameObject and the renderer draws it.

  2. Screenshot of the Moving with dt example

    Moving with dt

    A rectangle moves at a constant speed and bounces off the edges of the window.

  3. Screenshot of the Parent and child objects example

    Parent and child objects

    A parent adds children with addGameObject and moves them; destroying the parent destroys the children, then a new family spawns.

  4. Screenshot of the Hover and click example

    Hover and click

    Objects that define onMouseEntered, onMouseExit and onClick receive mouse events automatically.

  5. Screenshot of the Rotation, scale and flip example

    Rotation, scale and flip

    Sprites from a spritesheet quad drawn with rotation, rotationOrigin, scaleX/scaleY and flipX.

  6. Screenshot of the Tiling an image example

    Tiling an image

    repeatX and repeatY tile a quad across an area, clipping the last partial tile.

  7. Screenshot of the Custom draw() example

    Custom draw()

    Override draw() on a GameObject to render anything with love.graphics, in world space, in sort order.

Animation

Spritesheets, the AnimationManager and easing curves.

  1. Screenshot of the Spritesheet quads example

    Spritesheet quads

    A spritesheet preloaded with named frames; each frame is drawn by setting spritesheet and quad on an object.

  2. Screenshot of the Playing an animation example

    Playing an animation

    Every GameObject owns an AnimationManager: add frames, set one, update it each frame and draw it.

  3. Screenshot of the Switching animations by state example

    Switching animations by state

    A ghost floats when idle and waves while moving, flipping to face the direction of travel.

  4. Screenshot of the Per-frame callbacks example

    Per-frame callbacks

    onFrame callbacks fire when an animation reaches a frame; here each loop leaves a footprint.

  5. Screenshot of the Easing a value example

    Easing a value

    The easing curves in engine/utils/easing move four boxes from left to right and back.

Camera

Following, zooming, world versus screen space and shake.

  1. Screenshot of the Follow target example

    Follow target

    camera:followTarget keeps the player centred and clamps the view to the world bounds.

  2. Screenshot of the Zoom example

    Zoom

    setZoom magnifies the world about the screen centre; worldToScreen maps a world point to the screen.

  3. Screenshot of the World versus screen space example

    World versus screen space

    The camera scrolls; entities move with it while objects on the ui layer stay fixed on screen.

  4. Screenshot of the Screen shake example

    Screen shake

    Trauma-based shake: offsets the camera by seeded random amounts that decay back to rest.

Input

Action-based input, events, prompts, rebinding and focus.

  1. Screenshot of the Polling actions example

    Polling actions

    Read named actions with down, pressed, strength and vector instead of keys or buttons.

  2. Screenshot of the Action events example

    Action events

    Scenes and game objects receive onActionPressed and onActionReleased callbacks for named actions.

  3. Screenshot of the Input prompts example

    Input prompts

    InputPrompt draws the glyph for whatever an action is bound to on the active device; cycle the gamepad styles.

  4. Screenshot of the Rebinding at runtime example

    Rebinding at runtime

    rebind replaces an action's bindings for one device; isDefault and resetToDefaults track changes.

  5. Screenshot of the Menu navigation example

    Menu navigation

    A FocusGroup moves focus between Buttons with the ui_* actions and activates the focused one.

UI

Boxes, flex rows, text, buttons, bars and a HUD.

  1. Screenshot of the Boxes, padding and margins example

    Boxes, padding and margins

    UICanvas and UIBox stack children vertically; padding and margin are Vector4(top, right, bottom, left), and debug flags show them.

  2. Screenshot of the Flex row example

    Flex row

    display = "flex" with flexDirection = "row" lays children out horizontally, with gap, percentage widths, justifyContent and alignItems.

  3. Screenshot of the Text styles example

    Text styles

    UIText with the four contract fonts, colours, alignment and automatic wrapping that sets its own height.

  4. Screenshot of the Buttons example

    Buttons

    Button handles hover, click and keyboard activation; define onClick on the instance before adding it.

  5. Screenshot of the Progress bars example

    Progress bars

    UIBar shows a label, a value and a fill that changes colour as updateValue moves it.

  6. Screenshot of the A HUD example

    A HUD

    World objects and a screen-space HUD together: health bar, score and a hint, all bound to game state in update().

Collision

AABB overlap, rigid bodies, hit and hurt boxes, triggers.

  1. Screenshot of the Rectangle overlap example

    Rectangle overlap

    Axis-aligned overlap tests with rectangleIntersection and GameObject.rectsIntersect, highlighting the shared area.

  2. Screenshot of the Rigid bodies example

    Rigid bodies

    setRigidBody makes setPos refuse moves that would overlap another rigid body; debugShape shows the collision shapes.

  3. Screenshot of the Hit and hurt boxes example

    Hit and hurt boxes

    The HitHurtBox mixin gives objects offset hitboxes and hurtboxes; checkCollisionsWith finds targets of a class.

  4. Screenshot of the Trigger zones example

    Trigger zones

    A non-rigid zone detects when the player enters and leaves it using rect overlap tests each frame.

Lighting

Point lights with the LightManager.

  1. Screenshot of the Point lights example

    Point lights

    A LightManager darkens the scene to an ambient colour and adds coloured point lights on top.

  2. Screenshot of the A moving light example

    A moving light

    updateLightPosition moves a light each frame so a torch follows the player through the dark.

Post-processing

Full-screen shaders and shader chains.

  1. Screenshot of the Vignette shader example

    Vignette shader

    A full-screen shader declared on the example; the scene feeds it a uniform each frame through updateShaderUniforms.

  2. Screenshot of the Scanlines example

    Scanlines

    A time-driven shader: PostProcessing keeps a running clock and hands it to sendUniforms every frame.

  3. Screenshot of the Chaining shaders example

    Chaining shaders

    Several shaders run in order over the frame; each definition can be toggled with its enabled flag.

Utilities

Perlin noise, pathfinding, colours, vectors and serialisation.

  1. Screenshot of the Perlin noise example

    Perlin noise

    engine/utils/perlin samples 2D noise in 0..1; thresholds turn it into a terrain map.

  2. Screenshot of the Theta* pathfinding example

    Theta* pathfinding

    theta.findPath returns any-angle waypoints across a grid of walls; an agent walks the path.

  3. Screenshot of the Hex colours and vectors example

    Hex colours and vectors

    hexcolor turns "#rrggbb" strings into colour tables or Vector4s; Vector2 does the maths for an orbit.

  4. Screenshot of the Serialising tables example

    Serialising tables

    table_serialize turns plain data into deterministic Lua source and back; the save manager uses it.

State and saves

The State container and the save manager.

  1. Screenshot of the State container example

    State container

    engine/State holds game state with get, set and reset; the defaults are deep-copied so reset really restores them.

  2. Screenshot of the Saving and loading example

    Saving and loading

    saveManager writes one table to the save directory and reads it back; delete clears the slot and nothing ever throws.

  3. Screenshot of the Save versioning example

    Save versioning

    A migrate function upgrades older saves to the current schema; incompatible saves without one load as nil.

Device

Importing a file from the device, and the camera.

  1. Screenshot of the Picking a file example

    Picking a file

    filePicker opens the device's own picker and hands the file back as a drawable Image, as raw bytes, or as a file in the save directory.

  2. Screenshot of the Camera preview and capture example

    Camera preview and capture

    deviceCamera streams the device camera into one reused texture and takes stills; the preview is a love.Image you draw like any other.