Change run key to ctrl and some other messy stuff to make that work,,

This commit is contained in:
2026-09-27 20:10:03 -03:00
parent 966b517bbd
commit 2207eea1e1
4 changed files with 35 additions and 5 deletions
+9 -1
View File
@@ -23,7 +23,13 @@ import { TitleScreen } from "./gui/title_screen.ts";
import { DisconnectedScreen } from "./gui/disconnected_screen.ts";
// runs whatever is showing every frame: a menu screen before joining (and after leaving), or the game
export class ClientLoop {
export // while playing, the browser asks before leaving the page. sprinting is ctrl and walking is w, and ctrl+w closes the
// tab without the page getting a say. in fullscreen the keyboard lock catches it instead (see input_manager.ts)
function confirm_leaving(confirm: boolean) {
self.onbeforeunload = confirm ? (event) => event.preventDefault() : null;
}
class ClientLoop {
running = false;
last_time = 0;
client: Client | undefined;
@@ -54,6 +60,7 @@ export class ClientLoop {
show_screen(screen: GuiScreen) {
this.screen?.on_close();
this.client = undefined;
confirm_leaving(false);
this.screen = screen;
InputManager.set_mouse_grabbed(false);
}
@@ -65,6 +72,7 @@ export class ClientLoop {
this.screen?.on_close();
this.screen = undefined;
this.client = client;
confirm_leaving(true);
console.log("Game started");
}