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