Skip to content

Commit

Permalink
Animate changes in power.
Browse files Browse the repository at this point in the history
This prevents the displayed power bar from changing abruptly.
Actual power levels are unaffected by this patch.
  • Loading branch information
Cyp committed Nov 16, 2011
1 parent 8d7df45 commit 53e042b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/intdisplay.cpp
Expand Up @@ -556,9 +556,15 @@ void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
SDWORD iX,iY;
static char szVal[8];

double desiredPower = getPowerMinusQueued(selectedPlayer);
static double displayPower;
static unsigned lastRealTime;
displayPower = desiredPower + (displayPower - desiredPower)*exp((realTime - lastRealTime) / -80.); // If realTime < lastRealTime, then exp() returns 0 due to unsigned overflow.
lastRealTime = realTime;

ManPow = ManuPower / POWERBAR_SCALE;
Avail = getPowerMinusQueued(selectedPlayer) / POWERBAR_SCALE;
realPower = getPowerMinusQueued(selectedPlayer) - ManuPower;
Avail = displayPower / POWERBAR_SCALE;
realPower = displayPower - ManuPower;

BarWidth = BarGraph->width;
iV_SetFont(font_regular);
Expand Down

0 comments on commit 53e042b

Please sign in to comment.