# Making a mini-game for Rollick: guidelines

These guidelines are for anyone who builds a new Rollick mini-game, by hand or with an AI assistant (ChatGPT, Claude, Gemini…). A mini-game that follows them:

- passes the upload checks in the Rollick Studio,
- runs inside the Rollick player app on phones and tablets,
- can be configured by any game designer and plugged into a game's success conditions,
- looks and behaves like the other mini-games in the Rollick library.

**Start from the starter template** ([starter-template/](starter-template/) in the `rllck-bundles` repository, or the *Starter kit* download on the Rollick docs site, Game Design → Mini-games → Making a Mini-game). It is a small, complete mini-game that already does everything below. Replace its game, keep its plumbing.

**Working with an AI assistant?** Give it this file and the two files of `starter-template/`, then paste the [brief at the end](#brief-for-your-ai-assistant).

Rules marked **MUST** are checked or enforced by the platform: break them and the mini-game is refused, blocked or broken. Rules marked **SHOULD** are the house style of the Rollick library: an admin reviewing a shared mini-game expects them.

---

## The 12 rules at a glance

1. **MUST** be one folder with an `index.html` at its top, plus a `rollick.json`, zipped. No build step is needed on Rollick's side.
2. **MUST** include every file it uses (scripts, fonts, images, sounds). Nothing is loaded from the internet unless its host is declared.
3. **MUST** call `window.rollick.onComplete(result)` **exactly once**, when the game is over, with a small JSON object.
4. **SHOULD** report the standard result fields: `game`, `completed`, `success`, `score`, `maxScore` (100), `lang`.
5. **MUST** read its settings from `window.rollick.input`, and **SHOULD** fall back to URL query parameters and to sensible defaults when they are missing or wrong.
6. **SHOULD** speak Greek and English, choosing from the `lang` input, then the `language` input, then Greek.
7. **SHOULD** end with a popup that shows the outcome and a «Ολοκλήρωση αποστολής» / “Complete mission” button; tapping it sends the result.
8. **SHOULD** fit a phone screen in portrait without the page scrolling, and follow the [layout rules](#7-layout-and-mobile).
9. **MUST** be touch-first: no keyboard, no mouse hover, no right click required.
10. **MUST NOT** collect personal data, open other websites, show ads or track players.
11. **SHOULD** keep the zip small (ideally under 5 MB) so it loads quickly on mobile data.
12. **MUST** document every input and every result field in `rollick.json`, so other designers can use it without reading the code.

---

## 1. Package

```
my-mini-game/              ← folder name in kebab-case; also the `game` value in the result
├── index.html             ← the game (HTML, CSS and JS; one file is best)
├── rollick.json           ← the manifest: settings and library description
├── thumbnail.png          ← 512×512 picture for the library
└── (optional) assets: images, sounds, fonts, data
```

Limits checked on upload:

| | Limit |
|---|---|
| Zip | 50 MB, at most 2000 files and folders, at most 10 folders deep, paths up to 200 characters |
| Unpacked | 150 MB in all, 50 MB per file |
| Images | at most 16384 px on a side |
| Allowed file types | html, htm, css, js, mjs, json, txt, xml, csv, svg, png, jpg, jpeg, gif, webp, avif, ico, mp3, ogg, oga, wav, m4a, aac, mp4, webm, ogv, woff, woff2, ttf, otf, wasm, glb, gltf, bin, obj, mtl, atlas, fnt, data, ktx2, basis (and `.js.br`, `.wasm.br`, `.data.br`, `.gz` for Unity builds) |
| Refused | programs, archives inside the zip, symbolic links, password-protected zips, a `.well-known` folder, text files not in UTF-8 |

- Files whose names start with a dot (`.DS_Store`, `.git/`) are left out.
- Use **relative paths** (`img/sun.png`, not `/img/sun.png` and not `C:\…`).
- File names: lowercase, no spaces, no accents, no two names that differ only by case.
- Zip the folder that holds `index.html` (right-click → compress works). In the `rllck-bundles` repository, `./zip-bundle.sh my-mini-game` does it and also checks `rollick.json` and leaves out junk files.

## 2. `rollick.json`

Every field is optional for the upload, but the library needs them all. What a designer sets in the Studio wins over the file. Copy [starter-template/rollick.json](starter-template/rollick.json) and edit it.

| Field | What to put | Limits |
|---|---|---|
| `entry` | `"index.html"` | an HTML file in the zip |
| `allowedHosts` | `[]`, unless the game must call a server: `["api.example.org"]` | https host names only, at most 5, no wildcards, no IPs, no Rollick hosts. Cannot change once the mini-game is shared |
| `permissions` | `[]`, or some of `"camera"`, `"microphone"`, `"fullscreen"` | cannot change once shared |
| `orientation` | `"portrait"` (recommended), `"landscape"` or `"any"` | the app turns the screen for `landscape` |
| `title` | short, catchy, in English | 200 characters |
| `description` | what the student does, how the game ends, what it teaches, which inputs change it, and the language sentence (see below) | 3000 characters |
| `tags` | topic, skill, mechanic, and `"mobile"` | 8 tags, 30 characters each, lowercase |
| `credits` | authors, organisation, licences of third-party assets | 500 characters |
| `languages` | `["el-Gr", "en-Us"]` | only `el-Gr`, `en-Us`, or `"none"` for a game without text |
| `language` | the default, one of `languages`: `"el-Gr"` | |
| `thumbnail` | `"thumbnail.png"` | PNG, JPEG, GIF or WebP in the zip, at most 2 MB. **Not SVG** |
| `inputs` | `[{ "name", "description", "example" }]` | 20 inputs; names are letters, digits and `_`, starting with a letter; description 300 characters |
| `result` | `{ "description", "fields": [{ "name", "type", "description" }] }` | 20 fields; type is `number`, `string`, `boolean`, `object` or `array` |

Write descriptions for a game designer who will never read your code. End the `description` with:

> The interface is in Greek or English: the game's language, unless the `lang` input sets one.

For each input, say its **range, default, and what happens to bad values**, e.g.:

> Time limit in seconds (0–600, default 60). 0 means no time limit. The clock stops while a popup is open. Invalid values fall back to 60; values out of range are clamped.

## 3. Talking to Rollick: `window.rollick`

Rollick creates `window.rollick` **before** your page's scripts run, in the app, in the Studio preview and on the Rollick server. When you open `index.html` straight from your disk it does not exist: your game must still work.

```js
const ROLLICK = window.rollick || null;
const INPUT = (ROLLICK && ROLLICK.input) || {};
const QS = new URLSearchParams(location.search);   // fallback for local testing

// … at the very end, once:
if (ROLLICK && typeof ROLLICK.onComplete === 'function') ROLLICK.onComplete(result);
```

| API | What it does |
|---|---|
| `rollick.input` | An object with the task's settings (your inputs) and a few values Rollick always adds (below). |
| `rollick.onComplete(result)` | Reports the result. **Call it once.** The app records it, evaluates the task's success condition and **closes the mini-game straight away**, so show your results screen *before* calling it. A second call is ignored. |
| `rollick.close()` | Leaves without a result (optional; rarely needed). |
| `rollick.environment` | `"app"`, `"preview"` (Studio) or `"browser"`. Do not change the game's behaviour based on it. |

Values Rollick always puts in `rollick.input`:

| Name | Meaning |
|---|---|
| `language` | The language to run in: `el-Gr` or `en-Us` |
| `playerName` | The player's avatar name (may be empty) |
| `userId`, `gameId`, `instanceId` | Identifiers. Do not show them, do not send them anywhere |

**Do not** declare inputs named `userEmail`, `userId`, `gameId`, `instanceId` or `language` (`userEmail` is refused). Use `lang` and `playerName` with the meaning they have in every other mini-game.

## 4. Inputs

Inputs let one mini-game serve many games: easier or harder, shorter or longer, a different topic.

- **Parse everything.** Values may arrive as strings (`"6"`, `"true"`) or as numbers and booleans. Use `Number(...)`, check `isFinite`, round integers.
- **Validate and clamp.** Missing or invalid → the default. Out of range → the nearest allowed value. Never crash, never show `NaN`.
- **Booleans:** `"false"`, `"0"`, `"no"`, `"off"` mean false; anything else true.
- **Lists:** comma-separated strings, e.g. `topics=water,food,energy`; ignore unknown items.
- **Every input is optional.** With no inputs at all, the game must be playable and sensible.
- **Use the common names** when they fit: `seconds` (time limit, 0 = none), `tries` (attempts), `levels`, `rounds`, `difficulty` (`easy` / `medium` / `hard`), `hints`, `pass` (score needed to succeed), `lang`, `playerName`.
- **Log the resolved values** once at start, so a designer can debug in the Studio preview:

```js
console.log('[my-mini-game] input params:', { rollickInput: INPUT, url: location.search, resolved: { seconds, tries, lang } });
```

The starter template has `num()`, `bool()` and `text()` helpers that do all of this.

## 5. Language

```js
const LANG = /^en/i.test(String(INPUT.lang || INPUT.language || QS.get('lang') || 'el')) ? 'en' : 'el';
```

- `lang` (set by the designer) wins over `language` (the game's language, set by Rollick); default Greek.
- Keep **all visible text** in one dictionary per language (`T.el`, `T.en`); no text baked into images.
- Greek is the first language of most players: write it natively, with correct accents and final sigma (ς), not as a word-by-word translation.
- Set `document.documentElement.lang`.
- Report the language used as `lang: "el" | "en"` in the result.

## 6. The result

The result is how a game designer connects your mini-game to their game. In the Studio they write a success condition on it, such as `success == true` or `score >= 60`, and may store it for later. Make it predictable.

**Always send these fields:**

| Field | Type | Meaning |
|---|---|---|
| `game` | string | The folder name, e.g. `"mix-and-build"` |
| `completed` | boolean | Always `true` (the game ran to its end) |
| `success` | boolean | Did the player achieve the goal? Win → `true`, out of time / tries → `false` |
| `score` | number | 0–100, a whole number. Explain the formula in `rollick.json`. 0 on failure is the usual choice |
| `maxScore` | number | Always `100` |
| `lang` | string | `"el"` or `"en"` |

**Then add what is useful for this game:** attempts or mistakes used, `timeUsed` (seconds, one decimal), `timedOut`, hints used, level reached, and the **resolved inputs** (e.g. `seconds`, `tries`) so the result is self-explanatory.

Rules:

- **Plain JSON only:** numbers, strings, booleans, `null`, flat objects and arrays. No functions, dates, DOM elements or `undefined`.
- **Small:** under 4 KB once serialised (a larger result is not stored), at most 8 levels deep, 50 keys per object, 100 items per array. Prefer a flat object.
- **Stable names:** once published, do not rename or remove fields; other games' conditions depend on them. Add new ones instead.
- **No secrets and no personal data:** never include answers, codes, the player's name or anything typed by the player that could identify them.
- Field names: `camelCase`, letters and digits only.
- Log it before sending: `console.log('[my-mini-game] result:', result)`.

## 7. Layout and mobile

The mini-game runs full-screen in a phone's web view, usually held in portrait, sometimes on a tablet.

**Layout rules** (all library mini-games follow them; the starter template does too):

- **Portrait:** content in one column of cards, at most 520 px wide, centred.
- **Landscape (any height):** two cards side by side, **both filling 100% of the screen height**:
  - `body { height: 100dvh }`, `.app { height: 100%; grid-template-rows: minmax(0, 1fr) }`.
  - Each card has `min-height: 0` and `overflow: auto`: it scrolls inside itself if needed. **The page itself never scrolls.**
  - The part that should grow (board, canvas, list) fills the leftover space of its card. Size canvases from their box (`ResizeObserver`, `getBoundingClientRect`), never from `window.innerHeight`.
  - An extra `@media (orientation: landscape) and (max-height: 520px)` block holds compact sizes for phones.
- Use `100dvh`, not `100vh` (mobile browser bars).
- Respect the notch: `viewport-fit=cover` and `env(safe-area-inset-*)` padding.
- Check at **390×844** (phone portrait), **844×390** (phone landscape), **768×1024** and **1024×768** (tablet).

**Touch:**

- Tap targets at least 44×44 px; primary buttons bigger.
- Everything works with taps and drags. Use pointer events (`pointerdown/move/up`) so mouse and touch both work; set `touch-action: none` on dragged areas so the page does not scroll or zoom.
- No hover-only information, no keyboard-only controls, no double-tap or long-press as the only way to do something.
- Disable text selection and the tap highlight on the game area.
- `<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">`

**Look and feel:**

- Bold, high-contrast, readable at arm's length: body text at least 16 px.
- Respect `prefers-reduced-motion`.
- Sound is optional, never required to play, and starts only after a tap (browsers block autoplay). Offer a mute button if you use it.

## 8. Game flow

Every library mini-game follows the same shape, so players know what to do:

1. **Start popup:** a greeting (with `playerName` if given), a one-paragraph “how to play”, and a «Ξεκίνα» / “Start” button. **The clock starts only after it.**
2. **Play:** goal and status (time left, tries, score) always visible. A help button that reopens the instructions is welcome.
3. **Clocks stop while any popup is open** (help, fact cards, pause).
4. **End:** win, or lose (time out, no tries left). Pause briefly (~0.5 s) so the last move is seen, then show the **end popup**: a clear outcome, the score, one encouraging sentence, and a «Ολοκλήρωση αποστολής» / “Complete mission” button.
5. **Complete mission** → `rollick.onComplete(result)`. The app then closes the mini-game.

More:

- **Always reach an end.** Every path (win, lose, give up) must lead to the end popup and a result. Never leave the player stuck.
- Optional retries happen *inside* the game, before the result; once `onComplete` is called the game is over.
- Short sessions: 1–5 minutes with the default inputs.
- Randomise boards and questions where it makes sense, but every generated puzzle **must be solvable**.
- Be kind on failure: explain what went wrong and what the idea was. The player is learning.
- Don't save progress between sessions: each launch is a fresh game.

## 9. The sandbox: what is blocked

Rollick serves each mini-game from its own isolated address with a strict security policy. These are blocked unless stated:

| Blocked | What to do instead |
|---|---|
| Loading scripts, styles, fonts or images from the internet (CDNs, Google Fonts, unpkg…) | Put the files in the zip. Use system fonts or include `.woff2` files |
| Calling an API | Declare its host in `allowedHosts` (https only); the game must still end gracefully if it is offline |
| `<iframe>`, embedded videos (YouTube…) | Include short media files in the zip |
| Opening links, `window.open`, navigating to another site | Don't. Show the information inside the game |
| Service workers, cookies of Rollick, Rollick's own API | Not available |
| Camera, microphone, fullscreen without declaring them | Add them to `permissions`, **and** provide a fallback (e.g. tap instead of blow) for when the player refuses or the device has none |
| Forms posting to other sites | Not available |

Allowed: inline `<script>` and `<style>`, `eval`, WebAssembly, web workers, canvas, WebGL, Web Audio, `localStorage` (but don't rely on it).

Libraries are fine (Phaser, PixiJS, Three.js, Matter.js…) as long as their files are inside the zip. Plain HTML, CSS and JavaScript in one `index.html` is preferred for small games: easiest to review and fix.

## 10. Content, privacy and accessibility

- **Audience:** children and teenagers in schools, and visitors in museums and cities. Content must be age-appropriate, accurate, inclusive and free of violence, gambling mechanics and brand advertising.
- **Educational value:** say in the description what it teaches. Facts shown in the game must be correct and, where possible, sourced in `credits`.
- **Privacy:** collect nothing. No analytics, trackers, ads, external fonts or pixels. Don't ask for names, emails or photos; don't upload camera or microphone data anywhere.
- **Original or licensed assets only.** Credit third-party art, sounds and fonts and their licences in `credits`. Do not copy characters, art, music or levels from existing commercial games.
- **Accessibility:** good colour contrast; never use colour alone to carry meaning (add a shape, number or label); readable fonts; `aria-label`s on icon-only buttons; no flashing more than 3 times per second.

## 11. Performance

- The app waits about 8 seconds for a page to load (longer for big mini-games, up to 60 s). Aim for **under 5 MB** and a first screen in under 2 seconds on a mid-range phone.
- Compress images (WebP, sensible sizes: a 4000 px photo for a 400 px card is waste). Use `.mp3`/`.ogg` for sound.
- Keep animation at 60 fps on a mid-range phone; stop `requestAnimationFrame` loops when the game ends.
- Release the camera and microphone when done (`track.stop()`).

## 12. Testing checklist

Before uploading, open `index.html` in a desktop browser with the developer tools' **device toolbar** (mobile view), then go through:

- [ ] Opens with **no** query parameters, in Greek, and is playable.
- [ ] `?lang=en` switches every text to English; no Greek left, no text cut off.
- [ ] Each input changes the game as described; nonsense values (`?seconds=abc`, `?tries=-5`) fall back to defaults without errors.
- [ ] Win path and every lose path reach the end popup; “Complete mission” logs the result **once** (tap it twice: still once).
- [ ] The result matches `rollick.json`'s `result.fields`, has `game`, `completed`, `success`, `score`, `maxScore`, `lang`, and is under 4 KB.
- [ ] No errors in the console. No requests to other sites in the Network tab.
- [ ] Portrait 390×844 and landscape 844×390: nothing cut off, page does not scroll, all buttons reachable.
- [ ] Works with touch only (toggle touch simulation).
- [ ] The clock stops while popups are open.
- [ ] `rollick.json` is valid JSON and every input and result field is documented.
- [ ] `thumbnail.png` is 512×512, bold, readable at 64 px, without text.

Then in the **Rollick Studio**: upload the zip to your game, open the **preview**, check the console messages and the result it shows, and finally play it inside the **Rollick app** on a real phone.

## 13. Submitting to the library

1. Zip the folder (or, in `rllck-bundles`, `./zip-bundle.sh my-mini-game` → `dist/my-mini-game.zip`).
2. In the Studio, upload it to your game (Library → Mini-games). Fix every error the upload report lists; read the warnings.
3. Use it in an interactive External Task of your game and test it in the app.
4. **Share** it from its details in the Library. An admin reviews it before it appears in the Rollick library.

Once other games use a shared mini-game, its files, allowed hosts and permissions are fixed: a new version is a new upload. Get the inputs and result right before sharing.

---

## Brief for your AI assistant

Copy everything in the box below into your AI assistant, **attach this file, `starter-template/index.html` and `starter-template/rollick.json`**, and replace the parts in `<…>`.

```text
You are building a mini-game for the Rollick platform, an educational location-based game
platform. The mini-game runs inside the Rollick mobile app (a WebView) on phones and tablets.

GAME IDEA
- Name (kebab-case folder name): <my-mini-game>
- Topic and learning goal: <e.g. the water cycle, for students aged 10–14>
- What the player does: <core mechanic in 2–3 sentences>
- How it is won and how it is lost: <…>
- Settings a designer should be able to change (inputs): <e.g. seconds, tries, difficulty>

HARD REQUIREMENTS (follow the attached GUIDELINES.md exactly)
1. Start from the attached starter-template: keep its structure for input parsing (num/bool/text
   helpers with defaults and clamping), language selection, start popup, end popup, layout CSS
   and the single rollick.onComplete call. Replace only the game itself.
2. Output exactly two files: a self-contained index.html (all HTML, CSS and JS inline, no external
   URLs, no CDNs, no web fonts, no iframes, no links out) and rollick.json.
3. Read settings from window.rollick.input, falling back to URL query parameters, then defaults.
   Every input is optional. Values may be strings: parse, validate and clamp them.
4. Language: lang input, else language input, else Greek. Values starting with "en" select
   English. All visible text in a T.el / T.en dictionary. Write natural, correct Greek.
5. Flow: start popup with greeting (playerName) and how-to-play → play (clock starts after
   Start, pauses while popups are open) → end popup with outcome and score and a
   «Ολοκλήρωση αποστολής» / "Complete mission" button → that button calls
   window.rollick.onComplete(result) exactly once (guard against double taps; skip if
   window.rollick is missing). Every path must end there.
6. Result: a flat, JSON-safe object under 4 KB with game (= folder name), completed (true),
   success (boolean), score (integer 0–100), maxScore (100), lang ("el"|"en"), plus useful
   stats (attempts, timeUsed, timedOut…) and the resolved inputs. No answers or personal data.
7. Mobile-first: portrait one column max 520px; landscape two cards side by side at 100dvh,
   cards scroll inside, page never scrolls; compact block for landscape max-height 520px.
   Touch only (pointer events), targets ≥ 44px, safe-area insets, prefers-reduced-motion.
8. Log "[<my-mini-game>] input params:" at start and "[<my-mini-game>] result:" at the end.
9. Any generated puzzle must be solvable. Default inputs give a 1–5 minute session.
10. rollick.json: copy the template's shape; describe every input (range, default, fallback)
    and every result field (type and meaning, including the score formula). Languages
    ["el-Gr","en-Us"], default "el-Gr", orientation "portrait", thumbnail "thumbnail.png",
    empty allowedHosts and permissions unless the idea needs camera/microphone (then add a
    touch fallback).

When done, list how to test it locally with example query parameters, e.g.
<my-mini-game>/index.html?seconds=60&tries=3&lang=en
```

After the assistant answers, go through the [testing checklist](#12-testing-checklist) yourself. AI assistants often forget: the double-tap guard on “Complete mission”, pausing the clock in popups, clamping inputs, the landscape layout, and Greek accents.
