All Projects → fritzy → Ape Ecs

fritzy / Ape Ecs

Licence: mit
Entity-Component-System library for JavaScript.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ape Ecs

Godex
Godex is a Godot Engine ECS library.
Stars: ✭ 307 (+124.09%)
Mutual labels:  ecs, game-development, entity-component-system
Edyn
Edyn is a real-time physics engine organized as an ECS.
Stars: ✭ 113 (-17.52%)
Mutual labels:  ecs, game-development, entity-component-system
Etengine
Realtime 3D Game-Engine with a focus on space sim. Written in C++ 14
Stars: ✭ 408 (+197.81%)
Mutual labels:  ecs, game-development, entity-component-system
Defaultecs
Entity Component System framework aiming for syntax and usage simplicity with maximum performance for game development.
Stars: ✭ 286 (+108.76%)
Mutual labels:  ecs, game-development, entity-component-system
Svelto.ecs
Svelto ECS C# Lightweight Data Oriented Entity Component System Framework
Stars: ✭ 605 (+341.61%)
Mutual labels:  ecs, game-development, entity-component-system
Gdk For Unity
SpatialOS GDK for Unity
Stars: ✭ 296 (+116.06%)
Mutual labels:  ecs, game-development, entity-component-system
Ecs
A simple and easy to use entity-component-system C++ library
Stars: ✭ 20 (-85.4%)
Mutual labels:  ecs, game-development, entity-component-system
Entitas Cpp
Entitas++ is a fast Entity Component System (ECS) C++11 port of Entitas C#
Stars: ✭ 229 (+67.15%)
Mutual labels:  ecs, game-development, entity-component-system
Ecs
LeoECS is a fast Entity Component System (ECS) Framework powered by C# with optional integration to Unity
Stars: ✭ 578 (+321.9%)
Mutual labels:  ecs, game-development, entity-component-system
Entt
Gaming meets modern C++ - a fast and reliable entity component system (ECS) and much more
Stars: ✭ 6,017 (+4291.97%)
Mutual labels:  ecs, game-development, entity-component-system
Endless Runner Entitas Ecs
Runner template for Unity
Stars: ✭ 41 (-70.07%)
Mutual labels:  ecs, game-development, entity-component-system
Flecs
A fast entity component system (ECS) for C & C++
Stars: ✭ 2,201 (+1506.57%)
Mutual labels:  ecs, game-development, entity-component-system
Shipyard
Entity Component System focused on usability and speed.
Stars: ✭ 247 (+80.29%)
Mutual labels:  ecs, game-development, entity-component-system
Rust Game Development Frameworks
List of curated frameworks by the **Game Development in Rust** community.
Stars: ✭ 81 (-40.88%)
Mutual labels:  ecs, game-development, entity-component-system
Octopuskit
2D ECS game engine in 100% Swift + SwiftUI for iOS, macOS, tvOS
Stars: ✭ 246 (+79.56%)
Mutual labels:  ecs, game-development, entity-component-system
Kengine
Entity-Component-System (ECS) with a focus on ease-of-use, runtime extensibility and compile-time type safety and clarity.
Stars: ✭ 417 (+204.38%)
Mutual labels:  ecs, game-development, entity-component-system
Uecs
Ubpa Entity-Component-System (U ECS) in Unity3D-style
Stars: ✭ 174 (+27.01%)
Mutual labels:  ecs, game-development, entity-component-system
Entitas Csharp
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
Stars: ✭ 5,393 (+3836.5%)
Mutual labels:  ecs, game-development, entity-component-system
Entitas Sync Framework
Networking framework for Entitas ECS. Targeted at turnbased games or other slow-paced genres.
Stars: ✭ 98 (-28.47%)
Mutual labels:  ecs, game-development, entity-component-system
Gdk For Unity Fps Starter Project
SpatialOS GDK for Unity FPS Starter Project
Stars: ✭ 119 (-13.14%)
Mutual labels:  ecs, game-development, entity-component-system

Ape-ECS

Ape-ECS Hero

npm Build Status Coveralls github PRs Welcome

chat on discord @fritzy twitter

A performant, featureful, and flexible Entity-Component-System library for JavaScript, written in ECMAScript ES2018, intended for use in games and simulations.

Documentation

Install

npm install ape-ecs 

Differentiating Features

  • Advanced Queries for entities.
  • Persisted Queries (indexes) are updated as Entity composition changes.
  • Component reference properties to Entities (EntityRef, EntitySet, EntityObject)
    • When a referenced entity is destroyed, the property is updated to null.
    • Subscribe-able events for adding and removing references.
    • Reverse query from entity to entity-components that reference it.
  • Not all systems need to run every frame.
  • Export/import support for saving/restoring state with component-level serialization configuration.
  • 100% Test Coverage.

Example

const ApeECS = require('ape-ecs');

class Gravity extends ApeECS.System {
  init() {
    this.mainQuery = this.createQuery().fromAll('Position', 'Physics');
  }

  update(tick) {
    const entities = this.mainQuery.execute();
    const frameInfo = this.world.getEntity('frame');
    for (const entity of entities) {
      const point = entity.getOne('Position');
      if (!entity.has('Vector')) {
        entity.addComponent({
          type: 'Vector',
          mx: 0,
          my: 0
        })
      }
      const vector = entity.getOne('Vector');
      vector.my += 9.807 * frame.time.deltaTime * .01;
      vector.update();
    }
  }
}

class Position extends ApeECS.Component {}
Position.properties = {
  x: 0,
  y: 0
};

class Vector extends ApeECS.Component {

  get speed() {
    return Math.sqrt(this.mx**2 + this.my**2);
  }
}
Vector.properties = {
  mx: 0,
  my: 0,
  speed: 0
};

class FrameInfo extends ApeECS.Component {}
FrameInfo.properties = {
  deltaTime: 0,
  deltaFrame: 0,
  time: 0
};

const world = new ApeECS.World();
world.registerComponent(Position);
world.registerComponent(Vectory);
world.registerComponent(FrameInfo);
world.registerTags('Physics');
world.registerSystem('frame', Gravity);

const frame = world.createEntity({
  id: 'frame',
  c: {
    time: {
      type: 'FrameInfo',
    }
  }
})

// see world.creatEntity and world.createEntities
// in docs/World.md for more details
world.registerSystem('frame', require('./move.js'));
world.createEntities(require('./saveGame.json'));

let lastTime = 0;

function update(time) {
  const delta = time - lastTime;
  time = lastTime;
  frame.time.update({
    time: time,
    deltaTime: delta,
    deltaFrame: delta / 16.667
  });
  world.runSystems('frame');
  // run update again the next browser render call
  // every 16ms or so
  window.requestAnimationFrame(update);
}
update(0);

More About ECS

The Entity-Component-System paradigm is great for managing dynamic objects in games and simulations. Instead of binding functionality to data through methods, entities are dynamically composed of any combination of types. Separate systems are then able to query for entities with a given set of types.

ECS's dynamic data composition and freely interacting systems leads to:

  • More complex and dynamic composition than OOP
  • Improved performance due to lack of API methods
  • Emergent Gameplay with logical behavior extended beyond the programmer's vision.

This library has been inspired in part by:

Example Game

An in-progress arcade game Missile Orders.

This game is not in a complete state yet, nor does it show off all of the potential of ECS yet.

Running the Tests

The goal is to keep test coverage at 100%.

git clone [email protected]/fritzy/ape-ecs.git
cd ape-ecs
npm install
npm test

Contributors

  • Ben Morse -- Ben is an early adopter that provided a lot of insight and you have him to thank for the TypeScript definitions! Ben has a game, Super Game of Life that uses Ape ECS.

Special Thanks

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].