Coder Social home page Coder Social logo

dannyfritz / flock-ecs Goto Github PK

View Code? Open in Web Editor NEW
18.0 6.0 0.0 4.91 MB

๐Ÿฆ๐Ÿฆ๐Ÿฆ A simple, but powerful ECS written in TypeScript.

Home Page: https://dannyfritz.github.io/flock-ecs

License: MIT License

TypeScript 83.10% JavaScript 10.95% Shell 1.88% Handlebars 4.06%
typescript ecs entity-component-system gamedev entitycomponentsystem

flock-ecs's Introduction

โš ๏ธ This Project is Unmaintained

After many rewrites and finally finding a pattern I like, I realized that using TypedArrays is the way forward for a performant ECS in JS/TS. There are some patterns and such that were required to do it that are solved in this branch.

I recommend using this: bitECS. They are maintaining it better than I would and it is basically exactly what I was converging towards for Flock anyways. Plus, Phaser4 is using bitECS.

logo

GitHub npm badge

An entity component system (ECS) created with TypeScript in mind.

Features

  • No dependencies
  • Very good TypeScript typings
  • Simple, but powerful API
  • Designed for performance
  • Struct of Arrays for storing entity component values
  • Entities are queryable by:
    • Component
    • Absence of Component
    • Added Entity
    • Removed Entity
  • Systems can have 1 or more queries

Roadmap

Install

npm install flock-ecs
const flock = require("flock-ecs");
//or
import * as flock from "flock-ecs";

API Docs

Examples

Simple

import * as flock from 'flock-ecs';

const world = new flock.World();

const Position = new flock.Component(
  () => ({
    x: 0,
    y: 0,
  })
);
world.registerComponent(Position);

const logSystem = new flock.System(
  (entities) => {
    entities.forEach(entity => {
      const position = entity.getComponent(Position)!;
      console.log(`{ x: ${position.value.x}, y: ${position.value.y} }`);
    });
  },
  [ Position ],
);

for (let i=0; i<10; i++) {
  const entity = world.createEntity();
  entity.addComponent(Position, { x: Math.random() * 100, y: Math.random() * 100 });
}

logSystem.run(world);
world.maintain();

Boids

Development

This repo uses Yarn workspaces, so make sure you're using yarn instead of npm.

To build the library in watch mode:

yarn workspace flock-ecs dev

And then to live build one of the examples, in another terminal:

yarn workspace boids start

To run tests:

yarn test

To run tests in watch mode:

yarn test:dev

Code of Conduct

flock-ecs's People

Contributors

dannyfritz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flock-ecs's Issues

Roadmap to 1.0.0

Roadmap for flock-ecs

future

  • Guide
    • What is an ECS?
    • Best Practices
  • Examples
    • Turn Based Game
    • Platformer Game
  • Query Caching
  • Threading
  • Benchmarks
    • Against Other ECS's
    • Against OOP
  • Social such as Discord, gitter.im, or etc.
  • Move to a Github org
  • CD
    • Publish dev to npm
    • Publish latest to npm

1.0.0

  • Entity Pool
  • Logo
  • README.md
    • Shields
  • CONTRIBUTING.md
  • Documentation
  • Examples
    • Particle System
  • Tests
  • Linter
  • CI
    • Build Examples
    • Run Tests
    • Run Linter

0.1.0 โœ…

  • Entities (duh)
  • Components (duh)
  • Systems (duh)
  • World
  • Examples
    • Flocking / Boids
      • Code
      • README.md
    • Simple
      • Code
      • Comments
      • README.md
  • README.md
    • Quick Usage Example
    • Feature List
  • CHANGELOG.md
  • Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.