From 871d309952bd2963cb9099eb6c997e7a8a6e05f0 Mon Sep 17 00:00:00 2001 From: Exelo Date: Mon, 29 Dec 2025 03:49:10 +0100 Subject: [PATCH] docs: update README files with new structure and detailed usage examples for all packages --- packages/asset-manager/README.md | 83 ++++++++++++++++--- packages/common/README.md | 52 ++++++++---- packages/config/README.md | 133 ++++++++++++++++++++++++++++--- packages/core/README.md | 67 +++++++++++++--- packages/ecs-client/README.md | 125 ++++++++++++++++++++++++++++- packages/ecs-lib/README.md | 87 +++++++++----------- packages/ecs-server/README.md | 125 ++++++++++++++++++++++++++++- packages/graphics-2d/README.md | 108 ++++++++++++++++++++++--- packages/input/README.md | 82 ++++++++++++++++--- packages/music/README.md | 88 +++++++++++++++++--- packages/sound/README.md | 86 +++++++++++++++++--- utils/eslint-config/README.md | 63 ++++++++++++++- utils/prettier-config/README.md | 63 ++++++++++++++- 13 files changed, 1010 insertions(+), 152 deletions(-) diff --git a/packages/asset-manager/README.md b/packages/asset-manager/README.md index 48c39b4..1207edf 100644 --- a/packages/asset-manager/README.md +++ b/packages/asset-manager/README.md @@ -1,25 +1,84 @@ -# Engine Asset Manager +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-## Installing dependencies +## About -To install dependencies run: +`@nanoforge-dev/asset-manager` is a manager for loading assets to uniform work with between client and server. + +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/asset-manager +yarn add @nanoforge-dev/asset-manager +pnpm add @nanoforge-dev/asset-manager +bun add @nanoforge-dev/asset-manager ``` -## Building +## Example usage -To build the project run: +Initialize the library in your main file -```sh -pnpm build +```ts +import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager"; +import { type IRunOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; + +export async function main(options: IRunOptions) { + const app = NanoforgeFactory.createClient(); // Or NanoforgeFactory.createServer() + + const assetManager = new AssetManagerLibrary(); + + app.useAssetManager(assetManager); + + await app.init(options); + + await app.run(); +} ``` -## Tests +Use to load assets -To run tests use: +```ts +export async function mySystem(registry: Registry, ctx: Context) { + const assetManager = ctx.libs.getAssetManager(); -```sh -pnpm test + const file = assetManager.getAsset("/path/to/file.txt"); + const text = await file.text(); + + // Do something with file or text +} ``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/asset-manager +[npm]: https://www.npmjs.com/package/@nanoforge-dev/asset-manager +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/common/README.md b/packages/common/README.md index 7fe8c72..fe0087e 100644 --- a/packages/common/README.md +++ b/packages/common/README.md @@ -1,25 +1,49 @@ -# Engine Common +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-## Installing dependencies +## About -To install dependencies run: +`@nanoforge-dev/common` is library with common interfaces and utilities used by Nanoforge Engine. + +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/common +yarn add @nanoforge-dev/common +pnpm add @nanoforge-dev/common +bun add @nanoforge-dev/common ``` -## Building +## Links -To build the project run: +- [GitHub][source] +- [npm][npm] -```sh -pnpm build -``` +## Contributing -## Tests +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. -To run tests use: +## Help -```sh -pnpm test -``` +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/common +[npm]: https://www.npmjs.com/package/@nanoforge-dev/common +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/config/README.md b/packages/config/README.md index 41aa4db..99fd090 100644 --- a/packages/config/README.md +++ b/packages/config/README.md @@ -1,25 +1,134 @@ -# Engine Config +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-## Installing dependencies +## About -To install dependencies run: +`@nanoforge-dev/config` is a wrapper of [class-validator][class-validator] and [class-transformer][class-transformer] to imports validation and transformation decorators. + +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/config +yarn add @nanoforge-dev/config +pnpm add @nanoforge-dev/config +bun add @nanoforge-dev/config ``` -## Building +## Warning -To build the project run: +This library is of exclusive usage for other libraries. To put variables in the environment to allow libraries to use it through this config library, you must put it in factory options : -```sh -pnpm build +```ts +import { type IRunOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; +import { NetworkLibrary } from "@nanoforge-dev/network"; + +export async function main(options: IRunOptions) { + const app = NanoforgeFactory.createClient({ + environment: { + serverTcpPort: "4445", + serverUdpPort: "4444", + serverAddress: "127.0.0.1", + }, + }); + + const network = new NetworkLibrary(); + + app.useNetwork(network); + + await app.init(options); + + await app.run(); +} ``` -## Tests +## Example usage -To run tests use: +Initialize the library in your main file. -```sh -pnpm test +```ts +export class NetworkClientLibrary extends BaseNetworkLibrary { + get __name(): string { + return "NetworkClientLibrary"; + } + + public override async __init(context: InitContext): Promise { + const config = await context.config.registerConfig(ClientConfigNetwork); + + // Do something with config + } +} ``` + +Using this config + +```ts +import { + Default, + Expose, + IsByteLength, + IsIpOrFQDN, + IsOptional, + IsPort, +} from "@nanoforge-dev/config"; + +export class ClientConfigNetwork { + // This var must be a string port (ex: "4444") but can be undefined + @Expose() + @IsOptional() + @IsPort() + serverTcpPort?: string; + + @Expose() + @IsOptional() + @IsPort() + serverUdpPort?: string; + + // This var must be ip address or fqdn (it cannot be undefined) + @Expose() + @IsIpOrFQDN() + serverAddress?: string; + + // This var must be a byte length between 2 and 64. It can be undefined as it as a default value. + @Expose() + @Default("PACKET_END") + @IsByteLength(2, 64) + magicValue!: string; +} +``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/config +[npm]: https://www.npmjs.com/package/@nanoforge-dev/config +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md +[class-validator]: https://github.com/typestack/class-validator +[class-transformer]: https://github.com/typestack/class-transformer diff --git a/packages/core/README.md b/packages/core/README.md index bbb9215..0e40709 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -1,25 +1,66 @@ -# Engine Core +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-## Installing dependencies +## About -To install dependencies run: +`@nanoforge-dev/core` is a core package that contains game main loop. It is used to initialize the game and run it. + +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/core +yarn add @nanoforge-dev/core +pnpm add @nanoforge-dev/core +bun add @nanoforge-dev/core ``` -## Building +## Example usage -To build the project run: +Initialize the game in your main file. -```sh -pnpm build -``` +```ts +import { type IRunOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; -## Tests +export async function main(options: IRunClientOptions) { + const app = NanoforgeFactory.createClient(); -To run tests use: + await app.init(options); -```sh -pnpm test + await app.run(); +} ``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/core +[npm]: https://www.npmjs.com/package/@nanoforge-dev/core +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/ecs-client/README.md b/packages/ecs-client/README.md index 0b5eced..7065f4d 100644 --- a/packages/ecs-client/README.md +++ b/packages/ecs-client/README.md @@ -1 +1,124 @@ -# ECS Client +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
+ +## About + +`@nanoforge-dev/ecs-client` is a wrapper of `@nanoforge-dev/ecs-lib` for client-side usage. + +## Installation + +**Node.js 24.11.0 or newer is required.** + +```sh +npm install @nanoforge-dev/ecs-client +yarn add @nanoforge-dev/ecs-client +pnpm add @nanoforge-dev/ecs-client +bun add @nanoforge-dev/ecs-client +``` + +## Example usage + +Initialize the library in your main file. + +```ts +import { type IRunOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; +import { ECSClientLibrary } from "@nanoforge-dev/ecs-client"; + +export async function main(options: IRunClientOptions) { + const app = NanoforgeFactory.createClient(); + + const ecs = new ECSClientLibrary(); + + app.useComponentSystem(ecs); + + await app.init(options); + + const registry = ecs.registry; + + const entity = registry.spawnEntity(); + registry.addComponent(entity, new ExampleComponent("foo", 42)); + + registry.addSystem(exampleSystem); + + await app.run(); +} +``` + +With component + +```ts +export class ExampleComponent { + name = this.constructor.name; + + constructor( + public paramA: string, + public paramB: number, + public paramC: boolean = false, + ) {} + + get foo() { + return "bar"; + } + + get paramAOrDefault() { + return this.paramC ? this.paramA : "default"; + } + + addOne() { + this.paramB += 1; + } +} +``` + +And system + +```ts +export const exampleSystem = (registry: Registry, ctx: Context) => { + const entities = registry.getZipper([ExampleComponent]); + + entities.forEach((entity) => { + if (entity.ExampleComponent.paramA === "end") { + ctx.app.setIsRunning(false); + return; + } + + if (entity.ExampleComponent.paramB === 0) entity.ExampleComponent.paramA = "end"; + + if (entity.ExampleComponent.paramB >= 0) + entity.ExampleComponent.paramB = entity.ExampleComponent.paramB - 1; + }); +}; +``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/ecs-client +[npm]: https://www.npmjs.com/package/@nanoforge-dev/ecs-client +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/ecs-lib/README.md b/packages/ecs-lib/README.md index d4f3ddb..9c2309c 100644 --- a/packages/ecs-lib/README.md +++ b/packages/ecs-lib/README.md @@ -1,64 +1,55 @@ -# ECS Lib +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-> This lib doesn't work on its own. -> -> Please import `@nanoforge-dev/ecs-client` or `@nanoforge-dev/ecs-server` either +## About -## What is an ECS +`@nanoforge-dev/ecs-lib` is a powerful data structure for managing game entities. -"Entity–component–system (ECS) is a software architectural pattern mostly used in video game development for the representation of game world objects. An ECS comprises entities composed from components of data, with systems which operate on the components." -[Wikipedia](https://en.wikipedia.org/wiki/Entity_component_system) +## Installation -## How to build - -In order to build this ECS we need to first install a wasm compiler. For this project we gonna use `emsdk`. -You will also need `make` and `pnpm` - -### Installing dependencies - -To install dependencies run: +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/ecs-lib +yarn add @nanoforge-dev/ecs-lib +pnpm add @nanoforge-dev/ecs-lib +bun add @nanoforge-dev/ecs-lib ``` -#### How to install the emsdk compiler: - -To install emsdk the WASM compiler we are using run : +## Warning -```sh -git clone https://github.com/emscripten-core/emsdk.git -cd emsdk/ -./emsdk install latest -./emsdk activate latest -source "$PWD/emsdk_env.sh" -echo -ne "export EMSDK_QUIET=1\nsource \"$PWD/emsdk_env.sh\"\n" >> ~/.bashrc -cd .. -``` +This library is not usable on its own. You must use either the [ECS Client][ecs-client] or [ECS Server][ecs-server]. -### Building +## Links -Now that you have the dependencies you can build by running: +- [GitHub][source] +- [npm][npm] -```sh -pnpm build -``` +## Contributing -This will produce 2 files in the `lib/` directory. +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. -- `libecs.js`, which is the file containg the javascript binding permitting the javascript to interract with the wasm. -- `libecs.wasm`, the compile code library +## Help -If you only wanna build the c++ part just use: +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. -```sh -make -``` - -## Tests - -To run tests use: - -```sh -pnpm test -``` +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/ecs-lib +[npm]: https://www.npmjs.com/package/@nanoforge-dev/ecs-lib +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md +[ecs-client]: https://github.com/NanoForge-dev/Engine/tree/main/packages/ecs-client +[ecs-server]: https://github.com/NanoForge-dev/Engine/tree/main/packages/ecs-server diff --git a/packages/ecs-server/README.md b/packages/ecs-server/README.md index a5b680a..d5724bd 100644 --- a/packages/ecs-server/README.md +++ b/packages/ecs-server/README.md @@ -1 +1,124 @@ -# ECS Server +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
+ +## About + +`@nanoforge-dev/ecs-server` is a wrapper of `@nanoforge-dev/ecs-lib` for server-side usage. + +## Installation + +**Node.js 24.11.0 or newer is required.** + +```sh +npm install @nanoforge-dev/ecs-server +yarn add @nanoforge-dev/ecs-server +pnpm add @nanoforge-dev/ecs-server +bun add @nanoforge-dev/ecs-server +``` + +## Example usage + +Initialize the library in your main file. + +```ts +import { type IRunOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; +import { ECSServerLibrary } from "@nanoforge-dev/ecs-server"; + +export async function main(options: IRunServerOptions) { + const app = NanoforgeFactory.createServer(); + + const ecs = new ECSServerLibrary(); + + app.useComponentSystem(ecs); + + await app.init(options); + + const registry = ecs.registry; + + const entity = registry.spawnEntity(); + registry.addComponent(entity, new ExampleComponent("foo", 42)); + + registry.addSystem(exampleSystem); + + await app.run(); +} +``` + +With component + +```ts +export class ExampleComponent { + name = this.constructor.name; + + constructor( + public paramA: string, + public paramB: number, + public paramC: boolean = false, + ) {} + + get foo() { + return "bar"; + } + + get paramAOrDefault() { + return this.paramC ? this.paramA : "default"; + } + + addOne() { + this.paramB += 1; + } +} +``` + +And system + +```ts +export const exampleSystem = (registry: Registry, ctx: Context) => { + const entities = registry.getZipper([ExampleComponent]); + + entities.forEach((entity) => { + if (entity.ExampleComponent.paramA === "end") { + ctx.app.setIsRunning(false); + return; + } + + if (entity.ExampleComponent.paramB === 0) entity.ExampleComponent.paramA = "end"; + + if (entity.ExampleComponent.paramB >= 0) + entity.ExampleComponent.paramB = entity.ExampleComponent.paramB - 1; + }); +}; +``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/ecs-server +[npm]: https://www.npmjs.com/package/@nanoforge-dev/ecs-server +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/graphics-2d/README.md b/packages/graphics-2d/README.md index 63af5c0..c72628c 100644 --- a/packages/graphics-2d/README.md +++ b/packages/graphics-2d/README.md @@ -1,25 +1,109 @@ -# Engine Graphics 2D +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-## Installing dependencies +## About -To install dependencies run: +`@nanoforge-dev/graphics-2d` is a base 2D graphics library. + +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/graphics-2d +yarn add @nanoforge-dev/graphics-2d +pnpm add @nanoforge-dev/graphics-2d +bun add @nanoforge-dev/graphics-2d ``` -## Building +## Example usage -To build the project run: +Initialize the library in your main file with a red circle. -```sh -pnpm build +```ts +import { type IRunClientOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; +import { ECSClientLibrary } from "@nanoforge-dev/ecs-client"; +import { Circle, Graphics2DLibrary, Layer } from "@nanoforge-dev/graphics-2d"; + +import { CircleComponent } from "./components/CircleComponent"; + +export async function main(options: IRunClientOptions) { + const app = NanoforgeFactory.createClient(); + + const ecs = new ECSClientLibrary(); + const graphics = new Graphics2DLibrary(); + + app.useComponentSystem(ecs); + app.useGraphics(graphics); + + await app.init(options); + + const registry = ecs.registry; + + const layer = new Layer(); + graphics.stage.add(layer); + + const entity = registry.spawnEntity(); + registry.addComponent( + entity, + new CircleComponent( + new Circle({ + radius: 70, + fill: "red", + }), + layer, + ), + ); + + await app.run(); +} ``` -## Tests +With circle component defined. -To run tests use: +```ts +import { type Circle, type Layer } from "@nanoforge-dev/graphics-2d"; -```sh -pnpm test +export class CircleComponent { + name = "CircleComponent"; + component: Circle; + + constructor(component: Circle, layer: Layer) { + this.component = component; + layer.add(this.component); + } +} ``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/graphics-2d +[npm]: https://www.npmjs.com/package/@nanoforge-dev/graphics-2d +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/input/README.md b/packages/input/README.md index 978bd3e..acf5a7b 100644 --- a/packages/input/README.md +++ b/packages/input/README.md @@ -1,25 +1,83 @@ -# Engine Input +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-## Installing dependencies +## About -To install dependencies run: +`@nanoforge-dev/input` is an input manager for handling keyboard and mouse events. + +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/input +yarn add @nanoforge-dev/input +pnpm add @nanoforge-dev/input +bun add @nanoforge-dev/input ``` -## Building +## Example usage -To build the project run: +Initialize the library in your main file -```sh -pnpm build +```ts +import { type IRunClientOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; +import { InputLibrary } from "@nanoforge-dev/input"; + +export async function main(options: IRunClientOptions) { + const app = NanoforgeFactory.createClient(); + + const input = new InputLibrary(); + + app.useInput(input); + + await app.init(options); + + await app.run(); +} ``` -## Tests +Use to check for key presses -To run tests use: +```ts +export function mySystem(registry: Registry, ctx: Context) { + const input = ctx.libs.getInput(); -```sh -pnpm test + const isArrowUpPressed = input.isKeyPressed(InputEnum.ArrowUp); + + // Do something with the input +} ``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/input +[npm]: https://www.npmjs.com/package/@nanoforge-dev/input +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/music/README.md b/packages/music/README.md index 85a8e5b..a086872 100644 --- a/packages/music/README.md +++ b/packages/music/README.md @@ -1,27 +1,89 @@ -# Music +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-This is a basic music management library provided with nanoforge. +## About -## Installing dependencies +`@nanoforge-dev/music` is a music player for your game. -To install dependencies run: +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/music +yarn add @nanoforge-dev/music +pnpm add @nanoforge-dev/music +bun add @nanoforge-dev/music ``` -## Building +## Example usage -To build the project run: +Initialize the library in your main file -```sh -pnpm build +```ts +import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager"; +import { type IRunClientOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; +import { MusicLibrary } from "@nanoforge-dev/music"; + +export const MUSIC_SYM = Symbol("music"); + +export async function main(options: IRunClientOptions) { + const app = NanoforgeFactory.createClient(); + + const assetManager = new AssetManagerLibrary(); + const music = new MusicLibrary(); + + app.useAssetManager(assetManager); + app.use(MUSIC_SYM, music); + + await app.init(options); + + music.load("music", assetManager.getAsset("/path/to/music.mp3").path); + + await app.run(); +} ``` -## Tests +Use to play music -To run tests use: +```ts +export function mySystem(registry: Registry, ctx: Context) { + const assetManager = ctx.libs.getAssetManager(); + const music = ctx.libs.get(MUSIC_SYM); -```sh -pnpm test + music.play("music"); +} ``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/music +[npm]: https://www.npmjs.com/package/@nanoforge-dev/music +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/packages/sound/README.md b/packages/sound/README.md index 62a97db..bca6116 100644 --- a/packages/sound/README.md +++ b/packages/sound/README.md @@ -1,25 +1,87 @@ -# Sound +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
-## Installing dependencies +## About -To install dependencies run: +`@nanoforge-dev/sound` is a sound manager for your game. + +## Installation + +**Node.js 24.11.0 or newer is required.** ```sh -pnpm i +npm install @nanoforge-dev/sound +yarn add @nanoforge-dev/sound +pnpm add @nanoforge-dev/sound +bun add @nanoforge-dev/sound ``` -## Building +## Example usage -To build the project run: +Initialize the library in your main file -```sh -pnpm build +```ts +import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager"; +import { type IRunClientOptions } from "@nanoforge-dev/common"; +import { NanoforgeFactory } from "@nanoforge-dev/core"; +import { SoundLibrary } from "@nanoforge-dev/sound"; + +export async function main(options: IRunClientOptions) { + const app = NanoforgeFactory.createClient(); + + const assetManager = new AssetManagerLibrary(); + const sound = new SoundLibrary(); + + app.useAssetManager(assetManager); + app.useSound(sound); + + await app.init(options); + + sound.load("sound", assetManager.getAssetPath("/path/to/sound.mp3").path); + + await app.run(); +} ``` -## Tests +Use to play sound -To run tests use: +```ts +export function mySystem(registry: Registry, ctx: Context) { + const assetManager = ctx.libs.getAssetManager(); + const sound = ctx.libs.getSound(); -```sh -pnpm test + sound.play("sound"); +} ``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/sound +[npm]: https://www.npmjs.com/package/@nanoforge-dev/sound +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/utils/eslint-config/README.md b/utils/eslint-config/README.md index c26f3e9..38951c2 100644 --- a/utils/eslint-config/README.md +++ b/utils/eslint-config/README.md @@ -1 +1,62 @@ -# Utils Eslint Config +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
+ +## About + +`@nanoforge-dev/utils-eslint-config` is an ESLint configuration for Nanoforge projects. + +## Installation + +**Node.js 24.11.0 or newer is required.** + +```sh +npm install --save-dev @nanoforge-dev/utils-eslint-config +yarn add -D @nanoforge-dev/utils-eslint-config +pnpm add -D @nanoforge-dev/utils-eslint-config +bun add -d @nanoforge-dev/utils-eslint-config +``` + +## Example usage + +Use the configuration in your `eslint.config.js` file: + +```ts +import nanoforgeConfig from "@nanoforge-dev/utils-eslint-config"; + +export default { + ...nanoforgeConfig, + // Additional rules +}; +``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/utils/eslint-config +[npm]: https://www.npmjs.com/package/@nanoforge-dev/utils-eslint-config +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md diff --git a/utils/prettier-config/README.md b/utils/prettier-config/README.md index e926fdd..9ee47f7 100644 --- a/utils/prettier-config/README.md +++ b/utils/prettier-config/README.md @@ -1 +1,62 @@ -# Utils Prettier Config +
+
+

+ NanoForge +

+
+

+ npm version + npm downloads + Tests status + Last commit. +

+
+ +## About + +`@nanoforge-dev/utils-prettier-config` is an Prettier configuration for Nanoforge projects. + +## Installation + +**Node.js 24.11.0 or newer is required.** + +```sh +npm install --save-dev @nanoforge-dev/utils-prettier-config +yarn add -D @nanoforge-dev/utils-prettier-config +pnpm add -D @nanoforge-dev/utils-prettier-config +bun add -d @nanoforge-dev/utils-prettier-config +``` + +## Example usage + +Use the configuration in your `prettier.config.js` file: + +```ts +import nanoforgeConfig from "@nanoforge-dev/utils-prettier-config"; + +export default { + ...nanoforgeConfig, + // Additional rules +}; +``` + +## Links + +- [GitHub][source] +- [npm][npm] + +## Contributing + +Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the +[documentation][documentation]. +See [the contribution guide][contributing] if you'd like to submit a PR. + +## Help + +If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions]. + +[documentation]: https://github.com/NanoForge-dev/Engine +[discussions]: https://github.com/NanoForge-dev/Engine/discussions +[source]: https://github.com/NanoForge-dev/Engine/tree/main/utils/prettier-config +[npm]: https://www.npmjs.com/package/@nanoforge-dev/utils-prettier-config +[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md