Implement LifeMeterBar passing and LifeMeterBar extra passing, lifebars that display when the player is above the passmark.

This commit is contained in:
Ben Anderson
2004-11-12 03:44:15 +00:00
parent e9ed9d20ee
commit cdca8e1457
2 changed files with 33 additions and 0 deletions
+30
View File
@@ -27,6 +27,8 @@ public:
LifeMeterStream() LifeMeterStream()
{ {
bool bExtra = GAMESTATE->IsExtraStage()||GAMESTATE->IsExtraStage2(); bool bExtra = GAMESTATE->IsExtraStage()||GAMESTATE->IsExtraStage2();
// Here for my reference's sake, no reason to uncomment this
// bool bPassmark = GAMESTATE->m_CurrentPlayerOptions[m_playerNumber].m_fPassmark > 0;
m_quadMask.SetDiffuse( RageColor(0,0,0,1) ); m_quadMask.SetDiffuse( RageColor(0,0,0,1) );
m_quadMask.SetZ( 1 ); m_quadMask.SetZ( 1 );
@@ -46,6 +48,11 @@ public:
ID.filename = THEME->GetPathToG(sGraphicPath); ID.filename = THEME->GetPathToG(sGraphicPath);
m_sprStreamHot.Load( ID ); m_sprStreamHot.Load( ID );
m_sprStreamHot.SetUseZBuffer( true ); m_sprStreamHot.SetUseZBuffer( true );
sGraphicPath = ssprintf("LifeMeterBar %spassing", bExtra?"extra ":"");
ID.filename = THEME->GetPathToG(sGraphicPath);
m_sprStreamPassing.Load( ID );
m_sprStreamPassing.SetUseZBuffer( true );
sGraphicPath = ssprintf("LifeMeterBar %sframe", bExtra?"extra ":""); sGraphicPath = ssprintf("LifeMeterBar %sframe", bExtra?"extra ":"");
ID.filename = THEME->GetPathToG(sGraphicPath); ID.filename = THEME->GetPathToG(sGraphicPath);
@@ -54,11 +61,13 @@ public:
Sprite m_sprStreamNormal; Sprite m_sprStreamNormal;
Sprite m_sprStreamHot; Sprite m_sprStreamHot;
Sprite m_sprStreamPassing;
Sprite m_sprFrame; Sprite m_sprFrame;
Quad m_quadMask; Quad m_quadMask;
PlayerNumber m_PlayerNumber; PlayerNumber m_PlayerNumber;
float m_fPercent; float m_fPercent;
float m_fPassingAlpha;
float m_fHotAlpha; float m_fHotAlpha;
void GetChamberIndexAndOverslow( float fPercent, int& iChamberOut, float& fChamberOverflowPercentOut ) void GetChamberIndexAndOverslow( float fPercent, int& iChamberOut, float& fChamberOverflowPercentOut )
@@ -145,6 +154,7 @@ public:
m_sprStreamNormal.StretchTo( rect ); m_sprStreamNormal.StretchTo( rect );
m_sprStreamPassing.StretchTo( rect );
m_sprStreamHot.StretchTo( rect ); m_sprStreamHot.StretchTo( rect );
@@ -158,11 +168,14 @@ public:
1); 1);
m_sprStreamNormal.SetCustomTextureRect( frectCustomTexRect ); m_sprStreamNormal.SetCustomTextureRect( frectCustomTexRect );
m_sprStreamPassing.SetCustomTextureRect( frectCustomTexRect );
m_sprStreamHot.SetCustomTextureRect( frectCustomTexRect ); m_sprStreamHot.SetCustomTextureRect( frectCustomTexRect );
m_sprStreamPassing.SetDiffuse( RageColor(1,1,1,m_fPassingAlpha) );
m_sprStreamHot.SetDiffuse( RageColor(1,1,1,m_fHotAlpha) ); m_sprStreamHot.SetDiffuse( RageColor(1,1,1,m_fHotAlpha) );
m_sprStreamNormal.Draw(); m_sprStreamNormal.Draw();
m_sprStreamPassing.Draw();
m_sprStreamHot.Draw(); m_sprStreamHot.Draw();
} }
@@ -219,6 +232,7 @@ LifeMeterBar::LifeMeterBar()
m_fTrailingLifePercentage = 0; m_fTrailingLifePercentage = 0;
m_fLifeVelocity = 0; m_fLifeVelocity = 0;
m_fPassingAlpha = 0;
m_fHotAlpha = 0; m_fHotAlpha = 0;
m_bFailedEarlier = false; m_bFailedEarlier = false;
@@ -446,6 +460,18 @@ void LifeMeterBar::AfterLifeChanged()
} }
bool LifeMeterBar::IsPastPassmark() const
{
if( GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fPassmark > 0 )
{
return m_fLifePercentage >= GAMESTATE->m_PlayerOptions[m_PlayerNumber].m_fPassmark;
}
else
{
return false;
}
}
bool LifeMeterBar::IsHot() const bool LifeMeterBar::IsHot() const
{ {
return m_fLifePercentage >= 1; return m_fLifePercentage >= 1;
@@ -485,6 +511,9 @@ void LifeMeterBar::Update( float fDeltaTime )
m_fTrailingLifePercentage += m_fLifeVelocity * fDeltaTime; m_fTrailingLifePercentage += m_fLifeVelocity * fDeltaTime;
} }
m_fPassingAlpha += IsPastPassmark() ? +fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fPassingAlpha, 0, 1 );
m_fHotAlpha += IsHot() ? + fDeltaTime*2 : -fDeltaTime*2; m_fHotAlpha += IsHot() ? + fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fHotAlpha, 0, 1 ); CLAMP( m_fHotAlpha, 0, 1 );
@@ -497,6 +526,7 @@ void LifeMeterBar::Update( float fDeltaTime )
void LifeMeterBar::DrawPrimitives() void LifeMeterBar::DrawPrimitives()
{ {
m_pStream->m_fPercent = m_fTrailingLifePercentage; m_pStream->m_fPercent = m_fTrailingLifePercentage;
m_pStream->m_fPassingAlpha = m_fPassingAlpha;
m_pStream->m_fHotAlpha = m_fHotAlpha; m_pStream->m_fHotAlpha = m_fHotAlpha;
float fPercentRed = (m_fTrailingLifePercentage<DANGER_THRESHOLD) ? sinf( RageTimer::GetTimeSinceStart()*PI*4 )/2+0.5f : 0; float fPercentRed = (m_fTrailingLifePercentage<DANGER_THRESHOLD) ? sinf( RageTimer::GetTimeSinceStart()*PI*4 )/2+0.5f : 0;
+3
View File
@@ -25,6 +25,8 @@ public:
virtual void AfterLifeChanged(); virtual void AfterLifeChanged();
virtual void OnDancePointsChange() {}; // this life meter doesn't care virtual void OnDancePointsChange() {}; // this life meter doesn't care
virtual bool IsInDanger() const; virtual bool IsInDanger() const;
// XXX: Is this the best name for this function?
virtual bool IsPastPassmark() const;
virtual bool IsHot() const; virtual bool IsHot() const;
virtual bool IsFailing() const; virtual bool IsFailing() const;
virtual float GetLife() const { return m_fLifePercentage; } virtual float GetLife() const { return m_fLifePercentage; }
@@ -43,6 +45,7 @@ private:
float m_fTrailingLifePercentage; // this approaches m_fLifePercentage float m_fTrailingLifePercentage; // this approaches m_fLifePercentage
float m_fLifeVelocity; float m_fLifeVelocity;
float m_fPassingAlpha;
float m_fHotAlpha; float m_fHotAlpha;
bool m_bFailedEarlier; // set this to true when life dips below 0 bool m_bFailedEarlier; // set this to true when life dips below 0