silphius/app/ecs/components/forces.js

25 lines
602 B
JavaScript
Raw Normal View History

2024-06-26 21:08:09 -05:00
import Component from '@/ecs/component.js';
export default class Forces extends Component {
2024-07-02 08:05:36 -05:00
instanceFromSchema() {
return class ForcesInstance extends super.instanceFromSchema() {
applyForce({x, y}) {
this.forceX += x;
this.forceY += y;
}
applyImpulse({x, y}) {
this.impulseX += x;
this.impulseY += y;
}
}
}
2024-06-26 21:08:09 -05:00
static properties = {
2024-07-02 08:05:36 -05:00
dampingX: {type: 'float32'},
dampingY: {type: 'float32'},
2024-06-26 21:08:09 -05:00
forceX: {type: 'float32'},
forceY: {type: 'float32'},
impulseX: {type: 'float32'},
impulseY: {type: 'float32'},
};
2024-06-25 10:44:37 -05:00
}