Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
52e0f88
chore: add the examples layout, shared code check and ci
Exeloo Nov 13, 2026
cee71f2
feat(input-keyboard): add the keyboard input basic
Exeloo Nov 13, 2026
3186282
feat(input-mouse): add the mouse input basic
Exeloo Nov 13, 2026
b62068e
feat(graphics-3d): add the 3d graphics basic
Exeloo Nov 13, 2026
8f8e8d1
feat(raid-survival): add the workspace and the shared library of the …
Exeloo Nov 13, 2026
2890987
feat(raid-survival): port the server to engine 3
Exeloo Nov 13, 2026
595311c
feat(sound): add the sound effect basic
Exeloo Nov 13, 2026
560f620
feat(music): add the music track basic
Exeloo Nov 13, 2026
7002ca0
feat(sprite-2d): add the 2d sprite basic
Exeloo Nov 13, 2026
b8f27b9
feat(input-gamepad): add the controller input basic
Exeloo Nov 13, 2026
38e08a7
feat(scenes): add the scene switching basic
Exeloo Nov 13, 2026
88cd64c
feat(network): add the server-authoritative network basic
Exeloo Nov 13, 2026
c96cf96
ci: typecheck client and server workspaces per app
Exeloo Nov 13, 2026
f45eb49
chore: add the script that writes the music basic's tracks
Exeloo Nov 13, 2026
c125792
feat(flappy-bird): remake flappy bird for engine 3
Exeloo Nov 13, 2026
ab8f587
feat(tic-tac-toe): remake tic-tac-toe for engine 3
Exeloo Nov 13, 2026
110fb2e
chore: ignore only the root copies of the old games in prettier
Exeloo Nov 13, 2026
68721da
fix(raid-survival): check the vectors and the keys of the input messages
Exeloo Nov 13, 2026
f039da8
feat(raid-survival): port the client to engine 3 with menu, game and …
Exeloo Nov 13, 2026
0678420
docs(raid-survival): document running, the environment, the controls …
Exeloo Nov 13, 2026
091d405
chore(raid-survival): remove the old root game
Exeloo Nov 13, 2026
dcc6e54
docs(raid-survival): describe the collision, wave and zombie items of…
Exeloo Nov 13, 2026
5804439
feat(pong): add the local pong demo and the shared paddle code
Exeloo Nov 13, 2026
dc0004b
feat(pong-network): remake pong-network for engine 3 in demos
Exeloo Nov 13, 2026
0e5b615
feat(pong-3d): add the 3d peer-to-peer pong demo
Exeloo Nov 13, 2026
0e6a2fc
feat(breakout): add the breakout game made of scenes
Exeloo Nov 13, 2026
95a4707
fix(raid-survival): size the client viewport to the window
Exeloo Nov 13, 2026
4c02f9e
fix(raid-survival): restore the cursor after a game and match the tri…
Exeloo Nov 13, 2026
e1f0444
docs(raid-survival): document the client components and format the game
Exeloo Nov 13, 2026
63053b6
Merge branch 'feat/basics' into feat/centralize-games
Exeloo Nov 13, 2026
3ac44b0
Merge branch 'feat/paddle-games' into feat/centralize-games
Exeloo Nov 13, 2026
f349858
Merge branch 'feat/arcade-games' into feat/centralize-games
Exeloo Nov 13, 2026
0742dec
refactor: share one just-pressed helper and keep shared paths unique …
Exeloo Nov 13, 2026
7a1fe30
Merge branch 'feat/remake-raid-survival' into feat/centralize-games
Exeloo Nov 13, 2026
17b6fdf
refactor: share NetworkId across network games and name the pong prot…
Exeloo Nov 13, 2026
d232ce9
docs: list the examples and the shared components with their library …
Exeloo Nov 13, 2026
5030895
docs: fix the breakout layout, the raid-survival copies and the contr…
Exeloo Nov 13, 2026
cc17ceb
fix(raid-survival): give one lobby seat per session and normalize the…
Exeloo Nov 13, 2026
dc6d1db
fix(raid-survival): dispatch only to own handler keys
Exeloo Nov 13, 2026
665c6b7
style(raid-survival): use arrow functions and drop a debug log
Exeloo Nov 13, 2026
6b04704
refactor(raid-survival): use the shared velocity-2d component on the …
Exeloo Nov 13, 2026
3264ee2
refactor(raid-survival): use the shared draw-order-2d component for t…
Exeloo Nov 13, 2026
376d5c1
style(raid-survival): put package imports before relative ones
Exeloo Nov 13, 2026
a439a01
style(raid-survival): tag every system for the editor
Exeloo Nov 13, 2026
0c3f783
docs(raid-survival): list the client copies of velocity-2d and draw-o…
Exeloo Nov 13, 2026
552a5b1
docs(raid-survival): name what the floating texts show
Exeloo Nov 13, 2026
8dcea4f
style(raid-survival): sort the imports by path
Exeloo Nov 13, 2026
1a17d07
refactor(shared): share one scene var text between scenes, breakout a…
Exeloo Nov 13, 2026
5ac6fac
refactor(shared): share the 3d drawables between graphics-3d and pong-3d
Exeloo Nov 13, 2026
32f3db7
fix(shared): cap the ball speed-up and serve again a ball that left t…
Exeloo Nov 13, 2026
a558ed5
fix(breakout): put back on the paddle a ball out through the top or a…
Exeloo Nov 13, 2026
0364e39
fix(check): count every export form, nested folders and windows paths…
Exeloo Nov 13, 2026
ccd0c21
chore: stop tracking .idea and drop a stale prettierignore comment
Exeloo Nov 13, 2026
7de2280
docs: list the shared scene var text and 3d drawables, the ball recov…
Exeloo Nov 13, 2026
f54371b
fix(check): leave const enums out of the item count
Exeloo Nov 13, 2026
bf49a91
Merge branch 'fix/raid-survival-gate' into feat/centralize-games
Exeloo Nov 13, 2026
cbbf8d9
chore: run the check self-test in ci and fix the draw order and share…
Exeloo Nov 13, 2026
dfdc633
style(raid-survival): merge the duplicate imports
Exeloo Nov 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you wish to contribute to the NanoForge project, fork the repository and subm
To get ready to work on the codebase, please do the following:

1. Fork & clone the repository, and make sure you're on the **main** branch
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
3. Make your changes
4. Run `pnpm format && pnpm build && pnpm test:unit` to run ESLint/Prettier, build and tests
5. [Submit a pull request](https://github.com/NanoForge-dev/CLI/compare) (Make sure you follow the [conventional commit format](https://github.com/NanoForge-dev/CLI/blob/main/.github/COMMIT_CONVENTION.md))
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation)); each example has its own install too (`cd games/breakout && pnpm install`)
3. Make your changes. Read the [rules](../README.md#rules): one item per file, and shared files are edited in `shared/` then copied with `pnpm fix`
4. Run `pnpm lint` (prettier, one item per file, shared copies). In the example you changed, also run `pnpm exec tsc --noEmit` (per app for client and server examples) and `pnpm build`
5. [Submit a pull request](https://github.com/NanoForge-dev/examples/compare) (Make sure you follow the [conventional commit format](https://github.com/NanoForge-dev/examples/blob/main/.github/COMMIT_CONVENTION.md))
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Tests

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
lint:
name: Lint and shared code
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.list.outputs.examples }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 26
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm test
- id: list
run: echo "examples=$(node scripts/check.ts --list)" >> "$GITHUB_OUTPUT"

build:
name: Build ${{ matrix.example }}
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example: ${{ fromJSON(needs.lint.outputs.examples) }}
defaults:
run:
working-directory: ${{ matrix.example }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 26
- run: pnpm install --frozen-lockfile
# A client+server workspace is typechecked per app: their `Context` augmentations clash.
- run: |
if [ -d apps ]; then
for app in apps/*/; do pnpm exec tsc --noEmit -p "$app"; done
else
pnpm exec tsc --noEmit -p .
fi
- run: pnpm build
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
dist/
.nanoforge/
nf_modules/
.env
.idea/
10 changes: 0 additions & 10 deletions .idea/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/dictionaries/project.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/examples.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/prettier.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
pnpm-lock.yaml
dist/
.nanoforge/
nf_modules/
/.idea/
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 100
}
73 changes: 62 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,69 @@
<div align="center">
<br />
<p>
<a href="https://github.com/NanoForge-dev"><img src="https://github.com/NanoForge-dev/examples/blob/main/.github/logo.png" width="546" alt="NanoForge" /></a>
</p>
<br />
<img src=".github/logo.png" alt="NanoForge" width="120" />
<h1>NanoForge examples</h1>
</div>

## About
Games made with [NanoForge](https://nanoforge.eu). Each one is a project of its own, laid out as
`nf new` writes it, and opens in the editor (`nf editor <folder>`).

This repository contains the examples for NanoForge.
| Folder | What |
| --------- | ---------------------------------------------------------------------- |
| `basics/` | One engine feature each: the smallest game that shows it. |
| `demos/` | Small games around one idea (the pong family): local, networked, 3D. |
| `games/` | Complete games. |
| `shared/` | Components and systems several examples use, copied into each of them. |

## Examples in the repository
## Examples

- flappy-bird
- pong-network
- tic-tac-toe
| Example | Shows |
| ------------------------------------------------ | ----------------------------------------------------------- |
| [`basics/input-keyboard`](basics/input-keyboard) | Keyboard input: two squares moved with the arrows and WASD. |
| [`basics/input-mouse`](basics/input-mouse) | Mouse position, clicks and drag. |
| [`basics/input-gamepad`](basics/input-gamepad) | A controller's stick, buttons and rumble. |
| [`basics/sprite-2d`](basics/sprite-2d) | Images drawn from the assets folder. |
| [`basics/sound`](basics/sound) | Sound effects. |
| [`basics/music`](basics/music) | Music tracks. |
| [`basics/scenes`](basics/scenes) | Two scenes and their scene vars. |
| [`basics/network`](basics/network) | A client, a game server and a shared protocol library. |
| [`basics/graphics-3d`](basics/graphics-3d) | A lit, spinning cube in 3D. |
| [`demos/pong`](demos/pong) | Pong for two players on one keyboard, with scenes. |
| [`demos/pong-network`](demos/pong-network) | Pong over the network, run by a game server. |
| [`demos/pong-3d`](demos/pong-3d) | Pong in 3D, peer to peer, with the same server code. |
| [`games/breakout`](games/breakout) | Breakout: menu, three levels, pause and end screens. |
| [`games/flappy-bird`](games/flappy-bird) | Flappy Bird. |
| [`games/tic-tac-toe`](games/tic-tac-toe) | Tic-tac-toe for two players. |
| [`games/raid-survival`](games/raid-survival) | A co-op multiplayer zombie survival game. |

## Run an example

```sh
cd basics/input-keyboard
pnpm install
pnpm dev # or pnpm build && pnpm start
pnpm editor # open it in the NanoForge editor
```

Node 26 and pnpm 12. The examples depend on the latest NanoForge packages.

## Rules

- **One item per file**: each file under `components/` holds one component, each file under
`systems/` one system, each file under `scenes/` one scene (nested folders included). Types,
interfaces and enums that describe the item may sit next to it; any other export is a second
item. Items carry the editor's TSDoc tags (`@component`, `@system`, `@scene`, `@side`).
- **Shared code is copied, never imported**: an example must work on its own once copied out of
this repository. A file at `src/<path>` whose `<path>` exists in `shared/<group>/` must be an
exact copy of it. `pnpm check` fails on a copy that drifted; `pnpm fix` copies the shared version
over it. Change the file in `shared/`, then run `pnpm fix`.
- The shared files are temporary: [`docs/shared-components.md`](docs/shared-components.md) lists
them and the library package that should replace each one.

## Checks

```sh
pnpm install
pnpm lint # prettier + one item per file + shared copies
node --test scripts/check.test.ts # self-test of the check
```

CI also type-checks and builds every example (`.github/workflows/tests.yml`).
5 changes: 5 additions & 0 deletions basics/graphics-3d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
.nanoforge/
nf_modules/
.env
20 changes: 20 additions & 0 deletions basics/graphics-3d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# graphics-3d

A cube spinning in 3D, lit by a sun and the sky.

It shows the `graphics-3d` engine library (Three.js): `main` sets up the scene's background,
camera and lights through `Graphics3DLibrary`, and the cube is an entity: `Transform3D` places it,
`DrawableBox3D` draws it (the `draw3D` system adds its mesh to `ctx.graphics.scene`) and `Spin3D`
turns it (the `spin3D` system). graphics-3d renders the scene after the systems, every tick.

`Transform3D`, `DrawableBox3D`, `DrawableSphere3D` (a ball, unused here) and `draw3D` are copies
of `shared/3d` (see the repository's README); `demos/pong-3d` draws its table with them.

Three.js is a peer dependency of graphics-3d: import its classes from
`@nanoforge-dev/graphics-3d/three`.

```sh
pnpm install
pnpm dev # play it
pnpm editor # open it in the editor
```
Empty file.
5 changes: 5 additions & 0 deletions basics/graphics-3d/nanoforge.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from "@nanoforge-dev/config";

export default defineConfig({
type: "client",
});
26 changes: 26 additions & 0 deletions basics/graphics-3d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "graphics-3d",
"description": "A spinning cube: the smallest NanoForge game drawn in 3D",
"private": true,
"type": "module",
"scripts": {
"dev": "nf dev",
"build": "nf build",
"start": "nf start",
"editor": "nf editor ."
},
"devDependencies": {
"@nanoforge-dev/asset": "^3.0.0",
"@nanoforge-dev/cli": "^3.0.1",
"@nanoforge-dev/common": "^3.0.0",
"@nanoforge-dev/config": "^3.0.1",
"@nanoforge-dev/core": "^3.0.0",
"@nanoforge-dev/ecs": "^3.0.0",
"@nanoforge-dev/editor-lib": "^3.0.0",
"@nanoforge-dev/env": "^3.0.0",
"@nanoforge-dev/graphics-3d": "^3.0.0",
"three": "^0.187.0",
"typescript": "^6.0.0"
}
}
Loading
Loading