silphius/app/ecs-systems/apply-forces.js
2024-06-26 07:41:07 -05:00

19 lines
400 B
JavaScript

import {System} from '@/ecs/index.js';
export default class ApplyForces 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);
}
}
}