Skip to main content

Quiz

Quiz

setMode(.paddle) · posX, primaryAction

Quiz is a trivia game: four answers A–D, Open Trivia DB questions (with caching), solo or two-player rounds. The phone is the remote; questions can display on TV via AirPlay.

How you play

  1. Connect + calibrate.
  2. Open Quiz — pick category, language, solo/duo in the flow.
  3. Tilt to highlight A–D (posX → four slots).
  4. Press the cap button to confirm the highlighted answer (like a remote OK).
  5. Feedback shows correct/wrong; next question after a short pause.
  6. Touch on the phone still submits immediately (tap any answer).

Category pick (before the round) uses Triki UI with preferButtonConfirm: true — tilt to focus, button to pick (no hold auto-select).

VeltoKit mapping

SettingValue
MotionMode.paddle
SelectionposXTrikiSlotMath.slotIndex (4 answers)
ConfirmTrikiButtonConfirmGate on primaryAction (BLE edge + ~0.65 s cooldown)
Not usedHold timer, velocity triggers, shotTriggered, sensors.click as confirm

Same mode as Pong, different game logic — good example of reusing .paddle for menus.

Integrate in your app

let motion = MotionSDK()
motion.setMode(.paddle) // primaryAction = BLE button only in this mode
motion.connect()

var selected = 0
var confirmGate = TrikiButtonConfirmGate() // sample app helper

func tick(dt: TimeInterval) {
let input = motion.pollInput(deltaTime: dt)
let slot = TrikiSlotMath.slotIndex(posX: input.posX, slots: 4)
if slot != selected { selected = slot }

if confirmGate.consume(input: input, deltaTime: dt) {
submit(answer: selected)
}
}

Copy TrikiButtonConfirmGate from app/UI/TrikiUI/ or implement your own edge + cooldown on primaryAction.

Sample app source

FileRole
app/Games/QuizGame.swiftRounds, slot selection, TrikiButtonConfirmGate
app/UI/TrikiUI/TrikiButtonConfirmGate.swiftDebounced BLE confirm
app/UI/Quiz/QuizFlowView.swiftCategory pick + preferButtonConfirm
app/UI/QuizGameView.swiftQuestion UI
app/UI/Quiz/QuizExternalDisplay.swiftTV / second screen
app/Quiz/QuizSession.swiftLoader, categories, cache

TV: Enable AirPlay in the quiz flow; external display shows the question card, phone shows controls only.

Tips

  • Tune lateralDeadzone if the highlight jitters between A and B — Configuration.
  • Questions require network on first load; see QuizCache for offline rounds.

← Bowling · Triki UI navigation · Configuration · Demo · Help