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