23 lines
432 B
JavaScript
23 lines
432 B
JavaScript
import {System} from '@/ecs/index.js';
|
|
|
|
export default class ControlMovement extends System {
|
|
|
|
static queries() {
|
|
return {
|
|
default: ['Sprite'],
|
|
};
|
|
}
|
|
|
|
tick(elapsed) {
|
|
for (const {Sprite} of this.select('default')) {
|
|
Sprite.elapsed += elapsed / Sprite.speed;
|
|
while (Sprite.elapsed > 1) {
|
|
Sprite.elapsed -= 1;
|
|
Sprite.frame = (Sprite.frame + 1) % Sprite.frames;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|