Files
itgmania212121/stepmania/src/ScoreDisplayNormal.cpp
T

82 lines
1.8 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-07-23 01:41:40 +00:00
/*
-----------------------------------------------------------------------------
Class: ScoreDisplayNormal.h
Desc: A graphic displayed in the ScoreDisplayNormal during Dancing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ScoreDisplayNormal.h"
#include "RageUtil.h"
#include "RageLog.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "GameState.h"
#include "ThemeManager.h"
2002-07-23 01:41:40 +00:00
const float SCORE_TWEEN_TIME = 0.2f;
2002-07-23 01:41:40 +00:00
ScoreDisplayNormal::ScoreDisplayNormal()
{
LOG->Trace( "ScoreDisplayNormal::ScoreDisplayNormal()" );
2002-07-23 01:41:40 +00:00
// init the text
BitmapText::LoadFromNumbers( THEME->GetPathTo("Numbers","gameplay score numbers") );
2002-07-23 01:41:40 +00:00
TurnShadowOff();
m_fScore = 0;
2002-07-23 01:41:40 +00:00
m_fTrailingScore = 0;
m_fScoreVelocity = 0;
2002-07-23 01:41:40 +00:00
CString s;
for( int i=0; i<NUM_SCORE_DIGITS; i++ )
s += ' ';
SetText( s );
2002-07-23 01:41:40 +00:00
}
2002-07-28 20:28:37 +00:00
void ScoreDisplayNormal::Init( PlayerNumber pn )
2002-07-23 01:41:40 +00:00
{
m_PlayerNumber = pn;
}
void ScoreDisplayNormal::SetScore( float fNewScore )
{
m_fScore = fNewScore;
float fDelta = (float)m_fScore - m_fTrailingScore;
m_fScoreVelocity = fDelta / SCORE_TWEEN_TIME; // in score units per second
}
void ScoreDisplayNormal::Update( float fDeltaTime )
{
BitmapText::Update( fDeltaTime );
2002-07-28 20:28:37 +00:00
if( m_fTrailingScore != m_fScore )
2002-07-23 01:41:40 +00:00
{
2002-07-28 20:28:37 +00:00
float fDeltaBefore = (float)m_fScore - m_fTrailingScore;
m_fTrailingScore += m_fScoreVelocity * fDeltaTime;
float fDeltaAfter = (float)m_fScore - m_fTrailingScore;
2002-07-23 01:41:40 +00:00
2002-07-28 20:28:37 +00:00
if( fDeltaBefore * fDeltaAfter < 0 ) // the sign changed
{
m_fTrailingScore = (float)m_fScore;
m_fScoreVelocity = 0;
}
2002-07-23 01:41:40 +00:00
2002-10-25 05:06:38 +00:00
SetText( ssprintf("%*.0f", NUM_SCORE_DIGITS, m_fTrailingScore) );
2002-07-23 01:41:40 +00:00
}
}
2002-07-28 20:28:37 +00:00
void ScoreDisplayNormal::Draw()
2002-07-23 01:41:40 +00:00
{
2002-07-28 20:28:37 +00:00
BitmapText::Draw();
2002-07-23 01:41:40 +00:00
}