mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Support dynamic tick rates
This commit is contained in:
@@ -21,6 +21,7 @@ import { HUDPinnedShapes } from "./parts/pinned_shapes";
|
||||
import { ShapeDefinition } from "../shape_definition";
|
||||
import { HUDNotifications, enumNotificationType } from "./parts/notifications";
|
||||
import { HUDSettingsMenu } from "./parts/settings_menu";
|
||||
import { HUDDebugInfo } from "./parts/debug_info";
|
||||
|
||||
export class GameHUD {
|
||||
/**
|
||||
@@ -57,6 +58,7 @@ export class GameHUD {
|
||||
settingsMenu: new HUDSettingsMenu(this.root),
|
||||
|
||||
// betaOverlay: new HUDBetaOverlay(this.root),
|
||||
debugInfo: new HUDDebugInfo(this.root),
|
||||
};
|
||||
|
||||
this.signals = {
|
||||
|
||||
19
src/js/game/hud/parts/debug_info.js
Normal file
19
src/js/game/hud/parts/debug_info.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
import { makeDiv, round3Digits } from "../../../core/utils";
|
||||
|
||||
export class HUDDebugInfo extends BaseHUDPart {
|
||||
createElements(parent) {
|
||||
this.element = makeDiv(parent, "ingame_HUD_DebugInfo", []);
|
||||
|
||||
this.tickRateElement = makeDiv(this.element, null, ["tickRate"], "Ticks /s: 120");
|
||||
this.tickDurationElement = makeDiv(this.element, null, ["tickDuration"], "Update time: 0.5ms");
|
||||
}
|
||||
|
||||
initialize() {}
|
||||
|
||||
update() {
|
||||
this.tickRateElement.innerText = "Tickrate: " + this.root.dynamicTickrate.currentTickRate;
|
||||
this.tickDurationElement.innerText =
|
||||
"Avg. Dur: " + round3Digits(this.root.dynamicTickrate.averageTickDuration) + "ms";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user