19 lines
360 B
JavaScript
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;
|
|
}
|
|
}
|
|
|
|
}
|