silphius/app/ecs-systems/apply-momentum.js
2024-06-10 23:55:06 -05:00

19 lines
360 B
JavaScript

import {System} from '@/ecs/index.js';
export default class ApplyMomentum extends System {
static queries() {
return {
default: ['Position', 'Momentum'],
};
}
tick(elapsed) {
for (const [position, momentum] of this.select('default')) {
position.x += elapsed * momentum.x;
position.y += elapsed * momentum.y;
}
}
}