]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Sync oxygen bar blinking with start drowning time
authorterencehill <piuntn@gmail.com>
Sat, 21 Mar 2020 14:12:05 +0000 (15:12 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 21 Mar 2020 14:12:05 +0000 (15:12 +0100)
qcsrc/client/hud/panel/healtharmor.qc
qcsrc/client/miscfunctions.qc
qcsrc/client/miscfunctions.qh

index 9523be0e5e5df2bd628421b1ef4e0ac8886e4c36..1a61a96d3d1c90bad00b39a7f0fa79ddf9a181c8 100644 (file)
@@ -84,7 +84,7 @@ void HUD_HealthArmor()
        float air_alpha = 1;
        if (STAT(AIR_FINISHED) && time > STAT(AIR_FINISHED))
        {
-               air_alpha = blink(0.5, 0.5, 7);
+               air_alpha = blink_synced(0.5, 0.5, 7, STAT(AIR_FINISHED), -1);
                air_time = 10;
        }
 
index 2d0cf212d79f8b856a0d4ab8991f53c50bb6f796..d801ceabd7d7ccde6edf099e3aacd4b6f67b1a44 100644 (file)
@@ -216,7 +216,11 @@ vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float b
 
 // NOTE base is the central value
 // freq: circle frequency, = 2*pi*frequency in hertz
-float blink(float base, float range, float freq)
+// start_pos:
+//  -1 start from the lower value
+//   0 start from the base value
+//   1 start from the higher value
+float blink_synced(float base, float range, float freq, float start_time, int start_pos)
 {
        // note:
        //   RMS = sqrt(base^2 + 0.5 * range^2)
@@ -224,7 +228,12 @@ float blink(float base, float range, float freq)
        //   base = sqrt(RMS^2 - 0.5 * range^2)
        // ensure RMS == 1
 
-       return base + range * cos(time * freq);
+       return base + range * sin((time - start_time - (M_PI / 2) * start_pos) * freq);
+}
+
+float blink(float base, float range, float freq)
+{
+       return blink_synced(base, range, freq, 0, 0);
 }
 
 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag)
index 56bb176ef4649067d30c79578f16212a6b0c624b..3397ab7059133106f8f8a2008a44c619ac7dbafe 100644 (file)
@@ -52,6 +52,7 @@ float expandingbox_sizefactor_from_fadelerp(float fadelerp);
 
 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
 
+float blink_synced(float base, float range, float freq, float start_time, int start_blink);
 float blink(float base, float range, float freq);
 
 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);