Improve movement
This commit is contained in:
parent
7e188c2b9a
commit
c9eae3adeb
16 changed files with 227 additions and 279 deletions
|
|
@ -63,15 +63,6 @@
|
|||
|
||||
<div id="settings-container">
|
||||
<section id="settings">
|
||||
<label for="enable-relative-movement">
|
||||
<input id="enable-relative-movement" type="checkbox" />
|
||||
<img
|
||||
title="Make movement be relative to the gravitational field"
|
||||
alt="a dashed circle"
|
||||
src="../static/circle.svg"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label for="enable-vibration">
|
||||
<input id="enable-vibration" type="checkbox" />
|
||||
<img
|
||||
|
|
|
|||
|
|
@ -48,9 +48,6 @@ const toggleSettingsButton = document.querySelector(
|
|||
const minimize = document.querySelector('#minimize') as HTMLElement;
|
||||
const maximize = document.querySelector('#maximize') as HTMLElement;
|
||||
const logoutButton = document.querySelector('#logout') as HTMLElement;
|
||||
const enableRelativeMovement = document.querySelector(
|
||||
'#enable-relative-movement',
|
||||
) as HTMLInputElement;
|
||||
const enableSounds = document.querySelector('#enable-sounds') as HTMLInputElement;
|
||||
const enableMusic = document.querySelector('#enable-music') as HTMLInputElement;
|
||||
const enableVibration = document.querySelector('#enable-vibration') as HTMLInputElement;
|
||||
|
|
@ -123,7 +120,6 @@ const main = async () => {
|
|||
serverContainer.addEventListener('scroll', applyServerContainerShadows);
|
||||
|
||||
OptionsHandler.initialize({
|
||||
relativeMovementEnabled: enableRelativeMovement,
|
||||
soundsEnabled: enableSounds,
|
||||
vibrationEnabled: enableVibration,
|
||||
musicEnabled: enableMusic,
|
||||
|
|
|
|||
|
|
@ -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