{"id":16095498,"url":"https://github.com/sz-piotr/rook-ecs","last_synced_at":"2025-03-17T17:31:11.247Z","repository":{"id":23449052,"uuid":"99038786","full_name":"sz-piotr/rook-ecs","owner":"sz-piotr","description":"An Entity-Component-System library built for ease of use and code readability.","archived":false,"fork":false,"pushed_at":"2022-04-09T00:48:16.000Z","size":715,"stargazers_count":24,"open_issues_count":5,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T23:47:56.366Z","etag":null,"topics":["entity-component-system","library","simple-api","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sz-piotr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-01T20:05:13.000Z","updated_at":"2022-08-08T02:22:17.000Z","dependencies_parsed_at":"2022-07-25T13:32:04.500Z","dependency_job_id":null,"html_url":"https://github.com/sz-piotr/rook-ecs","commit_stats":null,"previous_names":["sz-piotr/ouyo"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sz-piotr%2Frook-ecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sz-piotr%2Frook-ecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sz-piotr%2Frook-ecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sz-piotr%2Frook-ecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sz-piotr","download_url":"https://codeload.github.com/sz-piotr/rook-ecs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243117569,"owners_count":20239150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["entity-component-system","library","simple-api","typescript"],"created_at":"2024-10-09T17:05:47.581Z","updated_at":"2025-03-17T17:31:10.892Z","avatar_url":"https://github.com/sz-piotr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg alt=\"logo\" src=\"https://raw.githubusercontent.com/sz-piotr/rook-ecs/master/logo.png\"\u003e\n\u003c/p\u003e\n\n# Rook\n\n[![npm](https://img.shields.io/npm/v/rook-ecs.svg)](https://www.npmjs.com/package/rook-ecs)\n[![Build Status](https://travis-ci.org/sz-piotr/rook-ecs.svg?branch=master)](https://travis-ci.org/sz-piotr/rook-ecs)\n![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/rook-ecs.svg)\n\nRook is a JavaScript library for creating games in the Entity-Component-System pattern.\nRook is currently a work in progress. All contributions are welcome.\n\n## Getting started\n\n### Install\n\n```\n$ npm install --save rook-ecs\n```\n\nor\n\n```\n$ yarn add rook-ecs\n```\n\nAfter installing you can include the library in the source\n\n```typescript\nimport { Game } from 'rook-ecs'\n\nconsole.log('Hurray!')\n```\n\n### Using UMD build in the browser\n\nAlternatively, you might want to use an UMD build in the browser.\nTo do so, grab the minified JavaScript file from\n[here](https://unpkg.com/rook-ecs/lib/rook-ecs.min.js)\nand add it to your site with a script tag.\n\nIn the browser all of the exports are available under the `Rook` global object.\n\n```html\n\u003cscript src=\"rook-ecs.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  console.log(Rook.Game)\n\u003c/script\u003e\n```\n\n## Usage Example\n\nFirst we declare the components. Components are just ids that correspond to some\ndata. In JavaScript you don't need to declare anything, just use pure strings.\n\nIn TypeScript there is a special `component` function that creates type safe\ncomponent ids.\n\n```typescript\nimport { component } from 'rook-ecs'\n\nexport interface Position {\n  x: number,\n  y: number,\n}\nexport const Position = component\u003cPosition\u003e('Position')\n\nexport interface Velocity {\n  x: number,\n  y: number,\n}\nexport const Velocity = component\u003cVelocity\u003e('Velocity')\n```\n\nHaving declared our components we can now use them in a system.\n\n```typescript\nimport { system, UpdateTick } from 'rook-ecs'\nimport { Position, Velocity } from './components'\n\nexport const move = system(UpdateTick, function (world, event) {\n  for (const entity of world.query(Position, Velocity)) {\n    const position = entity.get(Position)\n    const velocity = entity.get(Velocity)\n    position.x += velocity.x * event.deltaTime\n    position.y += velocity.y * event.deltaTime\n  }\n})\n```\n\nAnd just like this, all our entities that have both the `Position` and `Velocity`\ncomponents can now be updated with this system.\n\nThe only thing that's left is to start the game and create some entities.\n\n```typescript\nimport { start, gameClock } from 'rook-ecs'\nimport { Position, Velocity } from './components'\nimport { move } from './move'\n\nfunction init (world) {\n  world.create()\n    .set(Position, { x: 0, y: 0 })\n    .set(Velocity, { x: 10, y: 20 })\n}\n\nstart([\n  gameClock(),\n  init,\n  move,\n])\n```\n\n## Typescript support\n\nRook has first class TypeScript support since it is itself written with TypeScript.\nNo special compiler options have to be specified for Rook to work, although we\nrecommend using the `strict: true` setting.\n\n## Contributing\n\nRook is currently a work in progress. All contributions are welcome.\n\n## Useful reading\n\n* [TypeScript Documentation](https://www.typescriptlang.org/docs/home.html)\n* [T-Machine ECS Series](http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsz-piotr%2Frook-ecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsz-piotr%2Frook-ecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsz-piotr%2Frook-ecs/lists"}