# Build a blink game

> Build a face-controlled mini-game in Nosmai Studio by opening the BlinkFlyer template, previewing it, and learning how its script, game text, and reactions fit together. You play it by blinking, and the score and lives show on screen. This tutorial takes about 20 minutes and is the next step after your first filter.

> For AI agents: the complete documentation index is at https://nosmai.com/llms/studio.txt

Product: Nosmai Studio
Group: studio-tutorials
Source: https://nosmai.com/docs/studio/tutorials/build-a-blink-game/



## Overview

This tutorial builds a face-controlled mini-game by opening the **BlinkFlyer**
template and learning how its pieces fit: a Lua script drives the game, text layers
show the score and lives, and a blink controls play. By the end you will understand
how a game filter is assembled and how to change it.

**Product:** Nosmai Studio · **Platform:** macOS, Windows · **Updated:**
6 October 2026 · **Reading time:** 20 minutes

## Prerequisites

- You have finished [Make your first filter](/docs/studio/get-started/make-your-first-filter/).
- Everything mode, so the Code panel is available.
- A working camera.

## 1. Open the template

1. On the home screen, open **Templates**.
2. Open **BlinkFlyer**. It loads as editable layers.

## 2. Play it on a device

A game's Lua script runs on a device, not inside Studio, so you play the game on a
phone through the Companion app:

1. Connect a device. See [Preview on a device](/docs/studio/guides/preview-on-a-device/)
   for the full steps (same Wi-Fi, open the Companion app, it connects).
2. Send the filter to the device with **Preview on device**.
3. On the phone, blink to make the flyer move. The score and lives update on screen
   as you play.

In Studio's own preview you can see the game's layers, but the game does not play,
because Studio has no Lua interpreter. The game runs because the filter's type is
set to run as a game, which starts the Lua runtime on the device.

## 3. See how the game text works

The score, lives, and status you see are text layers bound to values the script
sets live:

1. Open the **Code** panel and find the script under **Scripts**.
2. The panel detects the text slots the script writes (score, lives, status,
   countdown) and shows whether each has a matching text layer.
3. If a slot had no text layer, nothing would show. The panel offers
   **Create the missing text layers** to fix that in one click.

This is the single most useful thing to understand about game filters: a script
writes to a named slot, and a text layer bound to that slot displays it.

## 4. Change something

Try one small change and preview it:

- In the Layers panel, select a text layer (for example the score) and change its
  **font** or **colour** in the inspector.
- Or open the script in the Code panel and change a number, such as how many lives
  the game starts with. The change runs the next time you preview on a device.

## 5. Check performance and export

1. Open the **Performance** view. A game is mostly shader and text, so it should
   read Good; the by-layer list shows what each piece costs.
2. Press **Export** and produce the `.nosmai` package when you are happy.

## Verify it worked

- Blinking controls the flyer in the preview.
- The score and lives update on screen as you play.
- The Code panel shows every text slot with a matching text layer.
- The exported folder contains a `.nosmai` file.

## Common problems

| What you see | Why | Fix |
| --- | --- | --- |
| The game does not respond to a blink | The filter is not set to run as a game | Set the filter to run as a game in the Code panel |
| The score or lives do not show | A written text slot has no matching text layer | Use "Create the missing text layers" in the Code panel |
| A script change did nothing | Studio has no Lua interpreter; scripts run on a device | Preview on a device, where the script runs |
| The flyer moves erratically | Blink detection needs a clear, well-lit face | Improve the lighting and face the camera directly |

## Next steps

- [Add a script or shader](/docs/studio/guides/scripting/)
- [Add text to a filter](/docs/studio/guides/add-text/)
- [Check performance](/docs/studio/guides/check-performance/)

## Reference

- [Layer kinds](/docs/studio/reference/layer-kinds/)
- [Glossary](/docs/studio/reference/glossary/)
