diff --git a/source/client/hud.qc b/source/client/hud.qc index ef11368..79d7930 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1925,6 +1925,35 @@ void(float width, float height) HUD_RoundStopWatch = Draw_String([width - (getTextWidth(stopwatch, 12)) - 2, 16], stopwatch, [12, 12], [1, 1, 1], 1, 0); } +/******************* +* HUD UPS * +*******************/ + +void() Draw_UPS = +{ + static float lastupstime; + static float lastups; + + if (!cvar("show_speed")) + return; + + if ((time - lastupstime) >= 1.0 / 20) + { + vector vel = [ + getstatf(STAT_VELOCITY_X), + getstatf(STAT_VELOCITY_Y), + getstatf(STAT_VELOCITY_Z) + ]; + + lastups = vlen(vel); + lastupstime = time; + } + + string str = sprintf("%3.1f UPS", lastups); + vector pos = [cvar("show_speed_x"), cvar("show_speed_y")]; + Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); +}; + /******************* * HUD Draw * *******************/ @@ -1999,6 +2028,8 @@ void(float width, float height) HUD_Draw = HUD_Scores(); HUD_Achievements(width, height); + + Draw_UPS(); if (screenflash_duration > time) HUD_Screenflash(); diff --git a/source/client/main.qc b/source/client/main.qc index cee2149..fa7e9eb 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -175,6 +175,9 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = autocvar(in_rumbleenabled, 1); autocvar(in_aimassist, 0); + cvar_set("show_speed_x", ftos(32)); + cvar_set("show_speed_y", ftos(32)); + // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") platform_is_web = true;