Improve movement

This commit is contained in:
schmelczerandras 2020-10-27 10:32:37 +01:00
parent 7e188c2b9a
commit c9eae3adeb
16 changed files with 227 additions and 279 deletions

View file

@ -35,9 +35,7 @@ export class KeyboardListener extends CommandGenerator {
if (vec2.squaredLength(movement) > 0) {
vec2.normalize(movement, movement);
}
this.sendCommandToSubcribers(
new MoveActionCommand(movement, OptionsHandler.options.relativeMovementEnabled),
);
this.sendCommandToSubcribers(new MoveActionCommand(movement));
}
private normalize(key: string): string {

View file

@ -75,18 +75,10 @@ export class TouchJoystickListener extends CommandGenerator {
vec2.set(movement, movement.x, -movement.y);
if (length > 10) {
this.sendCommandToSubcribers(
new MoveActionCommand(
vec2.normalize(movement, movement),
OptionsHandler.options.relativeMovementEnabled,
),
new MoveActionCommand(vec2.normalize(movement, movement)),
);
} else {
this.sendCommandToSubcribers(
new MoveActionCommand(
vec2.create(),
OptionsHandler.options.relativeMovementEnabled,
),
);
this.sendCommandToSubcribers(new MoveActionCommand(vec2.create()));
}
});
@ -104,12 +96,7 @@ export class TouchJoystickListener extends CommandGenerator {
} else if (event.touches.length === 0) {
this.isJoystickActive = false;
this.joystick.parentElement?.removeChild(this.joystick);
this.sendCommandToSubcribers(
new MoveActionCommand(
vec2.create(),
OptionsHandler.options.relativeMovementEnabled,
),
);
this.sendCommandToSubcribers(new MoveActionCommand(vec2.create()));
}
});
}