24 lines
531 B
JavaScript
24 lines
531 B
JavaScript
import {System} from '@/ecs/index.js';
|
|
|
|
export default class ControlDirection extends System {
|
|
|
|
tick() {
|
|
for (const {Controlled, Direction} of this.ecs.changed(['Controlled'])) {
|
|
const {moveUp, moveRight, moveDown, moveLeft} = Controlled;
|
|
if (moveUp > 0) {
|
|
Direction.direction = 0;
|
|
}
|
|
if (moveDown > 0) {
|
|
Direction.direction = 2;
|
|
}
|
|
if (moveLeft > 0) {
|
|
Direction.direction = 3;
|
|
}
|
|
if (moveRight > 0) {
|
|
Direction.direction = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|