Skip to content

Commit

Permalink
Added interpolation to crosshair size
Browse files Browse the repository at this point in the history
  • Loading branch information
Boondorl committed Nov 29, 2024
1 parent 72ed0c4 commit 426fe38
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/d_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ void D_Display ()
if (DrawFSHUD || automapactive) StatusBar->DrawAltHUD();
if (players[consoleplayer].camera && players[consoleplayer].camera->player && !automapactive)
{
StatusBar->DrawCrosshair();
StatusBar->DrawCrosshair(vp.TicFrac);
}
StatusBar->CallDraw (HUD_AltHud, vp.TicFrac);
StatusBar->DrawTopStuff (HUD_AltHud);
Expand Down
4 changes: 2 additions & 2 deletions src/g_statusbar/sbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,14 @@ class DBaseStatusBar : public DStatusBarCore
public:

AActor *ValidateInvFirst (int numVisible) const;
void DrawCrosshair ();
void DrawCrosshair (double ticFrac);

// Sizing info for ths status bar.
bool Scaled; // This needs to go away.

bool Centering;
bool FixedOrigin;
double CrosshairSize;
double PrevCrosshairSize, CrosshairSize;
double Displacement;
bool ShowLog;
int artiflashTick = 0;
Expand Down
11 changes: 7 additions & 4 deletions src/g_statusbar/shared_sbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ DBaseStatusBar::DBaseStatusBar ()
CompleteBorder = false;
Centering = false;
FixedOrigin = false;
CrosshairSize = 1.;
CrosshairSize = PrevCrosshairSize = 1.;
memset(Messages, 0, sizeof(Messages));
Displacement = 0;
CPlayer = NULL;
Expand Down Expand Up @@ -679,6 +679,8 @@ int DBaseStatusBar::GetPlayer ()

void DBaseStatusBar::Tick ()
{
PrevCrosshairSize = CrosshairSize;

for (size_t i = 0; i < countof(Messages); ++i)
{
DHUDMessageBase *msg = Messages[i];
Expand Down Expand Up @@ -988,7 +990,7 @@ void DBaseStatusBar::RefreshBackground () const
//
//---------------------------------------------------------------------------

void DBaseStatusBar::DrawCrosshair ()
void DBaseStatusBar::DrawCrosshair (double ticFrac)
{
if (!crosshairon)
{
Expand All @@ -1010,7 +1012,8 @@ void DBaseStatusBar::DrawCrosshair ()
}
int health = Scale(CPlayer->health, 100, CPlayer->mo->GetDefault()->health);

ST_DrawCrosshair(health, viewwidth / 2 + viewwindowx, viewheight / 2 + viewwindowy, CrosshairSize);
const double size = PrevCrosshairSize * (1.0 - ticFrac) + CrosshairSize * ticFrac;
ST_DrawCrosshair(health, viewwidth / 2 + viewwindowx, viewheight / 2 + viewwindowy, size);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -1082,7 +1085,7 @@ void DBaseStatusBar::Draw (EHudState state, double ticFrac)
{
if (CPlayer && CPlayer->camera && CPlayer->camera->player)
{
DrawCrosshair ();
DrawCrosshair (ticFrac);
}
}
else if (automapactive)
Expand Down

0 comments on commit 426fe38

Please sign in to comment.