Skip to content

Commit

Permalink
StatusBar: Normalize movement across screen resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemon-King committed Jul 1, 2024
1 parent b4db51a commit d53ded0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions resources/assets/zscript/statusbar/hxddstatusbar.zs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class HXDDStatusBar : BaseStatusBar {
const VIEW_SHIFT_RATE = 0.15;
const VIEW_SHIFT_DECAY = 0.85;

const BAR_SCREEN_WIDTH = 2560;
const BAR_SCREEN_HEIGHT = 1440;

const invAnimationDuration = 0.75;

private double shiftX;
Expand All @@ -21,6 +24,8 @@ class HXDDStatusBar : BaseStatusBar {
private double viewDist;
private double viewDistLast;

private vector2 screenScale;

private double invTime;


Expand Down Expand Up @@ -140,6 +145,9 @@ class HXDDStatusBar : BaseStatusBar {

UpdateProgression();

screenScale = (BAR_SCREEN_WIDTH, BAR_SCREEN_HEIGHT);
screenScale = (Screen.GetWidth() / screenScale.x, Screen.GetHeight() / screenScale.y);

if (prog) {
if (prog.ProgressionType == PSP_LEVELS) {
mXPInterpolator.Update(prog.levelpct);
Expand Down Expand Up @@ -252,6 +260,7 @@ class HXDDStatusBar : BaseStatusBar {
view.z += -self.vecMotion.y;
view.z += self.vecViewMotion.x;

view = (view.x * screenScale.x, view.y * screenScale.y, view.z * screenScale.x);
view *= self.GetVelocityScale();

vector2 v2Left = (view.x, view.y);
Expand Down

0 comments on commit d53ded0

Please sign in to comment.