Example game modules
The SDK includes thirteen games: six controller demos for the ways of holding the phone, and seven full games. Each supports one human player, with bots or a solo puzzle filling the other roles. Use the modules to explore input, motion, private screens and feedback in a working game. For rules and links to play, see the demo games.
| Game ID | Players | Phone controls |
|---|---|---|
racket-demo |
1 | Remote: the phone is the racket's handle, swings hit without a button, and the hand follows an arm model; touch or gamepad fallback. |
gamepad-demo |
1–4 | Every gamepad button and stick, shown live on the big screen; players drop in. |
shooter-demo |
1 | Remote: the phone is held like a gun, three shots line the aim up with the screen, a crosshair follows it; touch or gamepad fallback. |
plane-demo |
1 | Flight or gamepad: tilt to bank, roll and loop, throttle, flares, attitude display and rumble. |
car-demo |
1 | Wheel or gamepad: steering, pedals, GEAR UP and GEAR DN, RPM and shift lights. |
run-and-gun-demo |
1 | Remote with a stick under the other thumb (stickHand: 'other'): a first-person shooter; held like a gun, the phone aims, turns and fires while that thumb walks; touch or gamepad fallback. |
bumper-circuit |
1–8 | Wheel or gamepad, pedals, gears, RPM lights and rumble. |
sky-slalom |
1–4 | Flight or gamepad, throttle, attitude display and gate feedback. |
orbit-crew |
1–6 | Gamepad movement, fire, shield, dash and repair. |
midnight-table |
1–8 | Private roles and votes; surface or gamepad. |
ink-heist |
1–8 | Drawing tools and guess entry; surface or gamepad. |
signal-vault |
1–6 | Private clues, code dials and a shared hold action; surface or gamepad. |
rally-court |
1–4 | Remote swings, pointer aim and touch or gamepad fallback. |
Create a round
Import GAMES, GAME_LIST, createGame and restoreGame from @controller-plus/sdk/games, or /sdk/examples/games/index.mjs in a browser. GAME_LIST contains definitions and player limits; GAMES[id] supplies each module.
createGame(id, players, seed, options = {}) returns { module, state }. Each player needs id and name. The function checks the game's player-count limits.
With an existing direct host and at least one connected phone:
import { createGame } from '@controller-plus/sdk/games';
const players = host.state().room.players.filter(player => player.connected);
const { module: game, state } = createGame('bumper-circuit', players, 42);
const round = game.connect(host, state, { autoStart: false });
// In your simulation loop, pass elapsed seconds.
round.tick(1 / 60);
// Draw state.public on the shared screen. Keep the rest private.
// Close the binding before leaving the round or starting a rematch.
round.close();
Host bindings and renderers
Every game exposes connect(api, state, options), accepting a ControllerHost or RelayRoom. The binding provides inputs, tick(dt), sync() and close(). It listens for input and player lifecycle events, sends private views and feedback, and publishes public state. It owns a timer unless you pass autoStart: false. Closing it leaves your room and renderer open.
Ink Heist and Midnight Table also accept a modes map keyed by player ID, with surface or gamepad values. Signal Vault accepts controller: 'gamepad' in the createGame options. These are demo settings: surface and keyboard are not built-in phone view.modes values.
A phone reports the controller its player picked in MENU as a controller-mode event. The binding passes it to the game's setMode(id, mode, options) when the game has one (the six demos, Ink Heist and Rally Court do), so the game's text, views and input mapping follow the player's choice; in Remote mode options.hand is 'left' or 'right' (input). Racket Demo mirrors its arm for a left hand this way.
Rally Court uses the same binding and adds its own 3D renderer; the Rally Court guide covers its scoring, Remote swings and rumble. Racket Demo keeps every timestamped motion sample between ticks, so pass the input event's time through if you put your own host in front of it (Racket Demo). For the shared display, render.mjs supplies the 2D games' renderer; scene.mjs adds animation, interpolation and sound and loads each 3D renderer when needed.
Save a round
JSON.stringify(state) omits the random function and keeps its state in rngBox. Pass the parsed state to restoreGame(id, savedState) to rebuild the function. Save the whole state privately; broadcast only state.public. Your host still owns persistence and room credentials.
Select phone controls
Racket Demo, Shooter Demo, Run and Gun Demo and Rally Court request ['remote', 'gamepad'], Plane Demo and Sky Slalom request ['flight', 'gamepad'], Car Demo and Bumper Circuit request ['wheel', 'gamepad'], and Gamepad Demo and Orbit Crew request ['gamepad']. For a new title or mode list, the browser selects the first mode it supports. A player's MENU choice stays selected while that title and mode list remain the same. Keep both stable during readout updates.
Selecting a mode does not grant motion permission. Touch steering, aiming and buttons still work when motion is off or denied. See input mappings and Remote motion.
Handle reconnects
The bindings preserve a disconnected player's progress and release their input. Use disconnect to pause and removed for final departure. RelayRoom also reserves an unplugged local gamepad's seat for five minutes; returning in the same browser slot resumes it.
Bumper Circuit and Orbit Crew also expose connections(state, api, inputs), returning an unsubscribe function, for per-player connection badges and reserved seats. See connection quality. Decide how absence affects your game's timers, collisions and fairness.
For smaller complete hosts, start with Phaser, Wheel race, Flight or Private quiz. Headless tests cover software input and rendering. Sensors, grip, sound and physical vibration need device checks.