# Toy Engine

> An example game engine package: detects toy-engine.json projects, creates them, runs a tiny local game server shown in the game panel, and gives the agent two live tools.

- Id: `samples.toy-engine`
- Source: Community
- Category: Game engines
- Publisher: AI Game Dev Samples (`samples`)
- Latest version: 0.1.2 (published 2026-11-19)
- License: MIT
- Requires the AI Game Dev app: `>=0.32.0`
- Native code: no
- Rating: not rated yet
- HTML page: https://ai-game.dev/packages/samples.toy-engine

## Install

With the gamedev CLI, in the project folder:

```bash
gamedev pkg add samples.toy-engine
```

In the desktop app: open the Packages window (the package icon in the status bar), select **Browse**, search `samples.toy-engine` and click **Add to Project**. More: https://ai-game.dev/docs/wiki/app/packages

## Versions

| Version | Published | Requires app | Notes |
|---|---|---|---|
| 0.1.2 | 2026-11-19 | `>=0.32.0` | latest |
| 0.1.0 | 2026-11-19 | `>=0.32.0` | - |

## README

Written by the publisher, AI Game Dev Samples (`samples`); shown as published.

````markdown
# Toy Engine — an example game engine package

A complete game engine implemented by a package over the Extension Host (the `gameEngines` API, stable since
package API 0.4.0; SPEC "Engine API over the Extension Host"), with no native binaries:

- `aigd-package.json` — the declarative half: `contributes.gameEngines` (markers: a `toy-engine.json` file; no editor;
  `connection: "package"`; a browser game view; two starters with preview images in `media/`; a `showcase`: the
  colours, pitch, subtitle and tags of the create dialog). The App detects projects from it without running code.
- `extension.js` — the imperative half, registered with `aigd.gameEngines.registerEngine` in `activate()`:
  `project.create/validate`, `editor.launch` (starts `toy-server.cjs` with progress lines), `editor.stop`,
  `editor.gameView`, `editor.runIdentity`, `editor.health`, and the agent's live tools `get_state` / `set_ball`.
- `toy-server.cjs` — the "game": an HTTP server on `127.0.0.1` serving the project's `index.html` and a small control API.

Try it: [`docs/packages/TRY-IT.md` §8](../../TRY-IT.md#8-an-example-game-engine-package). The
contract, method by method: [`ENGINE-PACKAGES.md`](../../ENGINE-PACKAGES.md). `gamedev pkg init --engine` writes a
TypeScript copy of this package under your own id.
````
