Improve movement
This commit is contained in:
parent
7e188c2b9a
commit
c9eae3adeb
16 changed files with 227 additions and 279 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { ServerInformation, serverInformationEndpoint, TransportEvents } from 's
|
|||
import io from 'socket.io-client';
|
||||
import { Configuration } from './config/configuration';
|
||||
import parser from 'socket.io-msgpack-parser';
|
||||
import { SoundHandler, Sounds } from './sound-handler';
|
||||
|
||||
export type PlayerDecision = {
|
||||
playerName: string;
|
||||
|
|
@ -26,6 +27,7 @@ export class JoinFormHandler {
|
|||
});
|
||||
|
||||
form.onsubmit = (e) => {
|
||||
SoundHandler.play(Sounds.click);
|
||||
const result: PlayerDecision = (Array.from(
|
||||
(new FormData(form) as any).entries(),
|
||||
) as Array<[string, any]>).reduce((result, [name, value]) => {
|
||||
|
|
@ -113,6 +115,7 @@ class ServerChooserOption {
|
|||
this.inputElement.name = 'server';
|
||||
this.inputElement.checked = isFirst;
|
||||
this.labelElement.htmlFor = url;
|
||||
this.labelElement.onclick = () => SoundHandler.play(Sounds.click);
|
||||
this.divElement.appendChild(this.inputElement);
|
||||
this.divElement.appendChild(this.labelElement);
|
||||
this.labelElement.appendChild(this.serverNameElement);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { SoundHandler, Sounds } from './sound-handler';
|
|||
interface Options {
|
||||
vibrationEnabled: boolean;
|
||||
soundsEnabled: boolean;
|
||||
relativeMovementEnabled: boolean;
|
||||
musicEnabled: boolean;
|
||||
}
|
||||
|
||||
|
|
@ -12,7 +11,6 @@ export abstract class OptionsHandler {
|
|||
private static _options: Options = {
|
||||
vibrationEnabled: true,
|
||||
soundsEnabled: true,
|
||||
relativeMovementEnabled: false,
|
||||
musicEnabled: true,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue