26 lines
490 B
JavaScript
26 lines
490 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')) {
|
|
if (0 === Sprite.speed) {
|
|
continue;
|
|
}
|
|
Sprite.elapsed += elapsed / Sprite.speed;
|
|
while (Sprite.elapsed > 1) {
|
|
Sprite.elapsed -= 1;
|
|
Sprite.frame = (Sprite.frame + 1) % Sprite.frames;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|