silphius/app/ecs/systems/integrate-physics.js
2024-07-20 05:07:39 -05:00

19 lines
405 B
JavaScript

import {System} from '@/ecs/index.js';
export default class IntegratePhysics extends System {
static queries() {
return {
default: ['Position', 'Forces'],
};
}
tick(elapsed) {
for (const {Position, Forces} of this.select('default')) {
Position.x += elapsed * (Forces.impulseX + Forces.forceX);
Position.y += elapsed * (Forces.impulseY + Forces.forceY);
}
}
}