Rewrote first person HUD's drown numbers drawing

This commit is contained in:
Monster Iestyn 2017-04-13 22:09:03 +01:00
parent 63a16355da
commit 180829e95c
1 changed files with 39 additions and 53 deletions

View File

@ -78,12 +78,6 @@ static patch_t *race3;
static patch_t *racego;
static patch_t *ttlnum;
static patch_t *nightslink;
static patch_t *count5;
static patch_t *count4;
static patch_t *count3;
static patch_t *count2;
static patch_t *count1;
static patch_t *count0;
static patch_t *curweapon;
static patch_t *normring;
static patch_t *bouncering;
@ -272,12 +266,6 @@ void ST_LoadGraphics(void)
race3 = W_CachePatchName("RACE3", PU_HUDGFX);
racego = W_CachePatchName("RACEGO", PU_HUDGFX);
nightslink = W_CachePatchName("NGHTLINK", PU_HUDGFX);
count5 = W_CachePatchName("DRWNF0", PU_HUDGFX);
count4 = W_CachePatchName("DRWNE0", PU_HUDGFX);
count3 = W_CachePatchName("DRWND0", PU_HUDGFX);
count2 = W_CachePatchName("DRWNC0", PU_HUDGFX);
count1 = W_CachePatchName("DRWNB0", PU_HUDGFX);
count0 = W_CachePatchName("DRWNA0", PU_HUDGFX);
for (i = 0; i < 6; ++i)
{
@ -862,50 +850,48 @@ static void ST_drawFirstPersonHUD(void)
p = NULL;
// Display the countdown drown numbers!
if ((player->powers[pw_underwater] <= 11*TICRATE + 1
&& player->powers[pw_underwater] >= 10*TICRATE + 1)
|| (player->powers[pw_spacetime] <= 11*TICRATE + 1
&& player->powers[pw_spacetime] >= 10*TICRATE + 1))
{
p = count5;
}
else if ((player->powers[pw_underwater] <= 9*TICRATE + 1
&& player->powers[pw_underwater] >= 8*TICRATE + 1)
|| (player->powers[pw_spacetime] <= 9*TICRATE + 1
&& player->powers[pw_spacetime] >= 8*TICRATE + 1))
{
p = count4;
}
else if ((player->powers[pw_underwater] <= 7*TICRATE + 1
&& player->powers[pw_underwater] >= 6*TICRATE + 1)
|| (player->powers[pw_spacetime] <= 7*TICRATE + 1
&& player->powers[pw_spacetime] >= 6*TICRATE + 1))
{
p = count3;
}
else if ((player->powers[pw_underwater] <= 5*TICRATE + 1
&& player->powers[pw_underwater] >= 4*TICRATE + 1)
|| (player->powers[pw_spacetime] <= 5*TICRATE + 1
&& player->powers[pw_spacetime] >= 4*TICRATE + 1))
{
p = count2;
}
else if ((player->powers[pw_underwater] <= 3*TICRATE + 1
&& player->powers[pw_underwater] >= 2*TICRATE + 1)
|| (player->powers[pw_spacetime] <= 3*TICRATE + 1
&& player->powers[pw_spacetime] >= 2*TICRATE + 1))
{
p = count1;
}
else if ((player->powers[pw_underwater] <= 1*TICRATE + 1
&& player->powers[pw_underwater] > 1)
|| (player->powers[pw_spacetime] <= 1*TICRATE + 1
&& player->powers[pw_spacetime] > 1))
{
p = count0;
UINT32 airtime;
UINT32 frame = 0;
spriteframe_t *sprframe;
// If both air timers are active, use the air timer with the least time left
if (player->powers[pw_underwater] && player->powers[pw_spacetime])
airtime = min(player->powers[pw_underwater], player->powers[pw_spacetime]);
else // Use whichever one is active otherwise
airtime = (player->powers[pw_spacetime]) ? player->powers[pw_spacetime] : player->powers[pw_underwater];
if (!airtime)
return; // No air timers are active, nothing would be drawn anyway
airtime -= 1; // The original code was all n*TICRATE + 1, so let's remove 1 tic for simplicity
if (airtime > 11*TICRATE)
return; // Not time to draw any drown numbers yet
// Choose which frame to use based on time left
if (airtime <= 11*TICRATE && airtime >= 10*TICRATE)
frame = 5;
else if (airtime <= 9*TICRATE && airtime >= 8*TICRATE)
frame = 4;
else if (airtime <= 7*TICRATE && airtime >= 6*TICRATE)
frame = 3;
else if (airtime <= 5*TICRATE && airtime >= 4*TICRATE)
frame = 2;
else if (airtime <= 3*TICRATE && airtime >= 2*TICRATE)
frame = 1;
else if (airtime <= 1*TICRATE && airtime > 0)
frame = 0;
else
return; // Don't draw anything between numbers
if (player->charflags & SF_MACHINE)
frame += 6; // Robots use different drown numbers
// Get the front angle patch for the frame
sprframe = &sprites[SPR_DRWN].spriteframes[frame];
p = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE);
}
// Display the countdown drown numbers!
if (p)
V_DrawScaledPatch(SCX((BASEVIDWIDTH/2) - (SHORT(p->width)/2) + SHORT(p->leftoffset)), SCY(60 - SHORT(p->topoffset)),
V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, p);