25 lines
602 B
JavaScript
25 lines
602 B
JavaScript
import Component from '@/ecs/component.js';
|
|
|
|
export default class Forces extends Component {
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
static properties = {
|
|
dampingX: {type: 'float32'},
|
|
dampingY: {type: 'float32'},
|
|
forceX: {type: 'float32'},
|
|
forceY: {type: 'float32'},
|
|
impulseX: {type: 'float32'},
|
|
impulseY: {type: 'float32'},
|
|
};
|
|
}
|