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