Giter Club home page Giter Club logo

ecstasy-next's Introduction

ecstasy-next

A reducer based Entity-Component-System library for Javascript

Concepts

Basic pipeline:

  • View / Server etc
  • Action
  • Middleware (Middleware can fire another actions too)
  • System
  • Component
  • View

View

View displays game state / interacts with the user. If the user interacts with the interface, the interface would create an action and pass it into the action.

Views should send 'update' action every frame so the game state can change.

Action

Action represents a single action (or intent). Action can be dispatched by the user via the view, or external interrupts (such as remote server), etc.

Action should be plain JSON object, which means it should be serializable.

Action can have any props, but having type prop is greatly recommended.

Middleware

Middleware can 'drop' incoming action or dispatch another action after receiving the action, or it can edit the action appropriately.

Middlewares are chained - they'll be executed in an order.

System

Systems are reducers - They alter the current state according to the action. However, Unlike other Flux-style libraries, Systems alter the state directly without creating a copy. Thus, the state is mutable.

A system only manages single component. They can 'read' the whole state, but systems are not allowed to 'write' to any other component except single one.

Immutable state is much better to manage, but creating another copy every time an action is dispatched is too expensive in games, since there are more than 1000 entities on the game usually. To avoid this performance problem, the state is mutable. However, this doesn't mean that actions are mutable too, they're immutable.

Component

In Entity-Component-System, Component is a core element building up the Entity. This is same in this library too. Except, Entity doesn't exist as a 'Object'. Entity simply became a number - an unique ID representing the entity.

Only systems can alter the component. Mutating component outside system is not allowed. But this doesn't mean that reading is not allowed, only writing is not allowed, programs should dispatch an action to mutate the component.

Components should be plain JSON object - it should be serializable.

ecstasy-next's People

Contributors

yoo2001818 avatar

Watchers

 avatar  avatar  avatar

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.