yagl / ecs Goto Github PK
View Code? Open in Web Editor NEWEntity / Component / System pattern for ES6
Home Page: https://yagl.github.io/docs/ecs
Entity / Component / System pattern for ES6
Home Page: https://yagl.github.io/docs/ecs
Here is my (hypothetical, not actually implemented) simplified use case: in my game, when you click a button, all my physical entities explode, which results in their positions being modified.
To achieve this, I create an entity whenever I receive the event of the click of the button, with a component that marks that all entities should explode.
I have a system that reacts to this entity. When it's present, it creates an ExplosionSystem
which is responsible for updating the physical entities' positions. If it's not present, and the system is known by ECS, it removes it.
This approach has a few shortcomings:
ExplosionSystem
is lost when you remove it, which is bad for performanceExplosionSystem
is not reusable, and is needlessly recreatedExplosionSystem
can only be added after all the other systemsThis is my example, but it can be generalized to any case where an event results into the update of multiple different components.
It seems to me that if you were able to do mySystem.disable()
and mySystem.enable()
, all those problems would disappear. It would just be a matter of setting a flag on the disabled systems and checking that it's not present when updating the systems.
It's my first time using ECS, so maybe there is a better approach. I heard about it in this video about Entitas.
I'm looking at some recent small bug fixes on the original codebase and wondering the issues fixed also affect this fork?
and others
Looks like a really nice lib.
Tiny typo in the example that drives me a bit insane.
I do believe that you mean
class KeyboardControlSystem extends ECS.System {
and not
class KeyboardControlSystem extends ECS.Sytem {
Sorry if it seems like I'm nitpicking, but I felt like I ought to let you guys know.
on npmjs.org, yagl-ecs 1.1.0 has been released. On github, the version is still 1.0.0, leaving the new version undocumented as the source is the only documentation. Please update the source on github.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.