Improve settings
This commit is contained in:
parent
2509199abc
commit
81a8834c4d
19 changed files with 439 additions and 123 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { CommandGenerator, MoveActionCommand } from 'shared';
|
||||
import { OptionsHandler } from '../../options-handler';
|
||||
|
||||
export class KeyboardListener extends CommandGenerator {
|
||||
private keysDown: Set<string> = new Set();
|
||||
|
|
@ -34,7 +35,9 @@ export class KeyboardListener extends CommandGenerator {
|
|||
if (vec2.squaredLength(movement) > 0) {
|
||||
vec2.normalize(movement, movement);
|
||||
}
|
||||
this.sendCommandToSubcribers(new MoveActionCommand(movement, true));
|
||||
this.sendCommandToSubcribers(
|
||||
new MoveActionCommand(movement, OptionsHandler.options.relativeMovementEnabled),
|
||||
);
|
||||
}
|
||||
|
||||
private normalize(key: string): string {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
MoveActionCommand,
|
||||
} from 'shared';
|
||||
import { Game } from '../../game';
|
||||
import { OptionsHandler } from '../../options-handler';
|
||||
|
||||
export class TouchListener extends CommandGenerator {
|
||||
private previousPosition = vec2.create();
|
||||
|
|
@ -38,7 +39,9 @@ export class TouchListener extends CommandGenerator {
|
|||
|
||||
if (vec2.squaredLength(movement) > 0) {
|
||||
vec2.normalize(movement, movement);
|
||||
this.sendCommandToSubcribers(new MoveActionCommand(movement, false));
|
||||
this.sendCommandToSubcribers(
|
||||
new MoveActionCommand(movement, OptionsHandler.options.relativeMovementEnabled),
|
||||
);
|
||||
}
|
||||
|
||||
this.previousPosition = position;
|
||||
|
|
@ -46,7 +49,12 @@ export class TouchListener extends CommandGenerator {
|
|||
|
||||
target.addEventListener('touchend', (event: TouchEvent) => {
|
||||
event.preventDefault();
|
||||
this.sendCommandToSubcribers(new MoveActionCommand(vec2.create(), false));
|
||||
this.sendCommandToSubcribers(
|
||||
new MoveActionCommand(
|
||||
vec2.create(),
|
||||
OptionsHandler.options.relativeMovementEnabled,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue