Sounds on the client
This commit is contained in:
+15
-2
@@ -29,6 +29,7 @@ import { type BlockRegistry, EverythingRegistry } from "@/common/everything_regi
|
||||
import type { EntityJson } from "@/common/mod_data.ts";
|
||||
import { tick_texture_animations } from "./texture_animations.ts";
|
||||
import type { RenderBenchmark } from "./benchmark/benchmark.ts";
|
||||
import { sounds } from "./sounds.ts";
|
||||
|
||||
// holding the use button uses the held item on blocks again this often, like minecraft's 4 ticks
|
||||
const USE_REPEAT_MS = 200;
|
||||
@@ -136,12 +137,14 @@ export class Client {
|
||||
// leaving on purpose, from the pause screen
|
||||
disconnect() {
|
||||
this.#stopped = true;
|
||||
sounds.stop_all();
|
||||
this.connection.close();
|
||||
back_to_title();
|
||||
}
|
||||
|
||||
#stop() {
|
||||
this.#stopped = true;
|
||||
sounds.stop_all();
|
||||
this.level.dispose();
|
||||
InputManager.set_mouse_grabbed(false);
|
||||
}
|
||||
@@ -183,8 +186,18 @@ export class Client {
|
||||
this.#pending_time = Math.min(this.#pending_time, TICK_DELTA);
|
||||
}
|
||||
|
||||
if (this.benchmark) this.benchmark.render(this.#pending_time / TICK_DELTA);
|
||||
else this.game_renderer.render(this, this.#pending_time / TICK_DELTA);
|
||||
const partial_tick = this.#pending_time / TICK_DELTA;
|
||||
if (this.benchmark) {
|
||||
this.benchmark.render(partial_tick);
|
||||
} else {
|
||||
this.game_renderer.render(this, partial_tick);
|
||||
// from where the camera was just put
|
||||
sounds.frame(
|
||||
this.camera,
|
||||
(id) => this.level.entities.get(id)?.render_position(partial_tick),
|
||||
this.options.volume,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// one step of the game: what the server sent (chunks included), breaking, then every entity
|
||||
|
||||
Reference in New Issue
Block a user