Files
itgmania212121/stepmania/src/ScoreDisplayNormal.cpp
T

82 lines
1.8 KiB
C++
Raw Normal View History

2002-07-23 01:41:40 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
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"
const float SCORE_TWEEN_TIME = 0.5f;
ScoreDisplayNormal::ScoreDisplayNormal()
{
LOG->Trace( "ScoreDisplayNormal::ScoreDisplayNormal()" );
2002-07-23 01:41:40 +00:00
// init the text
BitmapText::LoadFromTextureAndChars( THEME->GetPathTo("Graphics","gameplay score numbers 7x2"), "01234 :56789%." );
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
CString sFormat = ssprintf( "%%%d.0f", NUM_SCORE_DIGITS );
SetText( ssprintf(sFormat, m_fTrailingScore) );
}
}
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
}