
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Ape-ECS (Apex) Entity-Component-System library for simulation and game development.
A performant, featureful, and flexible Entity-Component-System library for JavaScript, written in ECMAScript ES2018, intended for use in games and simulations.
npm install ape-ecs
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 {
static properties = {
x: 0,
y: 0
}
}
class Vector extends ApeECS.Component {
static properties = {
mx: 0,
my: 0,
speed: 0
}
get speed() {
return Math.sqrt(this.mx**2 + this.my**2);
}
}
class FrameInfo extends ApeECS.Component {
static 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);
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:
This library has been inspired in part by:
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.
The goal is to keep test coverage at 100%.
git clone git@github.com/fritzy/ape-ecs.git
cd ape-ecs
npm install
npm test
1.3.1 February 1, 2021
FAQs
Ape-ECS (Apex) Entity-Component-System library for simulation and game development.
The npm package ape-ecs receives a total of 64 weekly downloads. As such, ape-ecs popularity was classified as not popular.
We found that ape-ecs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.