From 0f9056ac989175acbeec3bfe8d774924b5b6ba3d Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 17 Jan 2002 07:41:01 +0000 Subject: [PATCH] NEW FEATURE: Animated score while dancing --- stepmania/src/Player.cpp | 13 ++- stepmania/src/Player.h | 7 +- stepmania/src/ScoreDisplay.cpp | 63 ------------- stepmania/src/ScoreDisplayRolling.cpp | 88 +++++++++++++++++++ .../{ScoreDisplay.h => ScoreDisplayRolling.h} | 18 ++-- stepmania/src/StepMania.dsp | 12 ++- 6 files changed, 120 insertions(+), 81 deletions(-) delete mode 100644 stepmania/src/ScoreDisplay.cpp create mode 100644 stepmania/src/ScoreDisplayRolling.cpp rename stepmania/src/{ScoreDisplay.h => ScoreDisplayRolling.h} (53%) diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 410795a439..9a68957ef2 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -217,8 +217,7 @@ Player::Player( PlayerOptions po, PlayerNumber pn ) // score m_sprScoreFrame.Load( THEME->GetPathTo(GRAPHIC_SCORE_FRAME) ); - m_textScoreNumber.Load( THEME->GetPathTo(FONT_SCORE_NUMBERS) ); - m_textScoreNumber.SetText( " " ); + m_ScoreDisplay.SetScore( 0 ); SetX( CENTER_X ); @@ -1357,19 +1356,19 @@ void Player::ChangeLife( StepScore score ) void Player::SetScoreX( int iNewX ) { - m_sprScoreFrame.SetXY( (float)iNewX, SCORE_Y ); - m_textScoreNumber.SetXY( (float)iNewX, SCORE_Y ); + m_sprScoreFrame.SetXY( iNewX, SCORE_Y ); + m_ScoreDisplay.SetXY( iNewX, SCORE_Y ); } void Player::UpdateScore( float fDeltaTime ) { m_sprScoreFrame.Update( fDeltaTime ); - m_textScoreNumber.Update( fDeltaTime ); + m_ScoreDisplay.Update( fDeltaTime ); } void Player::DrawScore() { - m_textScoreNumber.Draw(); + m_ScoreDisplay.Draw(); m_sprScoreFrame.Draw(); } @@ -1410,5 +1409,5 @@ void Player::ChangeScore( StepScore score, int iCurCombo ) ASSERT( m_fScore >= 0 ); - m_textScoreNumber.SetText( ssprintf("%9.0f", m_fScore) ); + m_ScoreDisplay.SetScore( m_fScore ); } \ No newline at end of file diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index af7b251dad..2ad0d65d00 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -25,6 +25,7 @@ #include "Player.h" #include "ActorFrame.h" #include "SoundSet.h" +#include "ScoreDisplayRolling.h" @@ -145,9 +146,9 @@ private: void UpdateScore( float fDeltaTime ); void DrawScore(); void ChangeScore( StepScore stepscore, int iCurCombo ); - float m_fScore; - Sprite m_sprScoreFrame; - BitmapText m_textScoreNumber; + float m_fScore; + Sprite m_sprScoreFrame; + ScoreDisplayRolling m_ScoreDisplay; // assist SoundSet m_soundAssistTick; diff --git a/stepmania/src/ScoreDisplay.cpp b/stepmania/src/ScoreDisplay.cpp deleted file mode 100644 index 26a43313e6..0000000000 --- a/stepmania/src/ScoreDisplay.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "stdafx.h" -/* ------------------------------------------------------------------------------ - File: ScoreDisplay.h - - Desc: A graphic displayed in the ScoreDisplay during Dancing. - - Copyright (c) 2001 Chris Danford. All rights reserved. ------------------------------------------------------------------------------ -*/ - -#include "ScoreDisplay.h" -#include "RageUtil.h" -#include "ThemeManager.h" - - - - -ScoreDisplay::ScoreDisplay() -{ - RageLog( "ScoreDisplay::ScoreDisplay()" ); - - for( int i=0; iGetPathTo(FONT_SCORE_NUMBERS) ); - m_textDigits[i].TurnShadowOff(); - - // get the width of the numbers - m_textDigits[i].SetText( "0" ); - float fCharWidth = m_textDigits[i].GetWidestLineWidthInSourcePixels(); - - m_textDigits[i].SetText( " " ); - - float fCharOffsetsFromCenter = i - float(MAX_SCORE_DIGITS-1)/2; - - m_textDigits[i].SetXY( fCharOffsetsFromCenter * fCharWidth, 0 ); - - this->AddActor( &m_textDigits[i] ); - } - - SetScore( 0 ); -} - - -void ScoreDisplay::SetScore( float fNewScore ) -{ - CString sFormatString = ssprintf( "%%%d.0f", MAX_SCORE_DIGITS ); - CString sScore = ssprintf( sFormatString, fNewScore ); - - for( int i=0; iGetPathTo(FONT_SCORE_NUMBERS) ); + m_textDigits[i].TurnShadowOff(); + + // get the width of the numbers + m_textDigits[i].SetText( "0" ); + float fCharWidth = m_textDigits[i].GetWidestLineWidthInSourcePixels(); + + m_textDigits[i].SetText( " " ); + + float fCharOffsetsFromCenter = i - float(MAX_SCORE_DIGITS-1)/2; + + m_textDigits[i].SetXY( fCharOffsetsFromCenter * fCharWidth, 0 ); + + iCurrentScoreDigits[i] = 0; + iDestinationScoreDigits[i] = 0; + + this->AddActor( &m_textDigits[i] ); + } + + m_fTimeUntilNextTick = 0; + + SetScore( 0 ); +} + + +void ScoreDisplayRolling::SetScore( float fNewScore ) +{ + // super inefficient (but isn't called very often) + CString sFormatString = ssprintf( "%%%d.0f", MAX_SCORE_DIGITS ); + CString sScore = ssprintf( sFormatString, fNewScore ); + + for( int i=0; i 9 ) + iCurrentScoreDigits[i] = 0; + + m_textDigits[i].SetText( ssprintf("%d", iCurrentScoreDigits[i]) ); + } + } + } +} + diff --git a/stepmania/src/ScoreDisplay.h b/stepmania/src/ScoreDisplayRolling.h similarity index 53% rename from stepmania/src/ScoreDisplay.h rename to stepmania/src/ScoreDisplayRolling.h index b859289703..0599c643fc 100644 --- a/stepmania/src/ScoreDisplay.h +++ b/stepmania/src/ScoreDisplayRolling.h @@ -1,16 +1,16 @@ /* ----------------------------------------------------------------------------- - File: ScoreDisplay.h + File: ScoreDisplayRolling.h - Desc: A graphic displayed in the ScoreDisplay during Dancing. + Desc: A graphic displayed in the ScoreDisplayRolling during Dancing. Copyright (c) 2001 Chris Danford. All rights reserved. ----------------------------------------------------------------------------- */ -#ifndef _ScoreDisplay_H_ -#define _ScoreDisplay_H_ +#ifndef _ScoreDisplayRolling_H_ +#define _ScoreDisplayRolling_H_ #include "Sprite.h" @@ -22,14 +22,20 @@ const int MAX_SCORE_DIGITS = 9; -class ScoreDisplay : public ActorFrame +class ScoreDisplayRolling : public ActorFrame { public: - ScoreDisplay(); + ScoreDisplayRolling(); void SetScore( float fNewScore ); + virtual void Update( float fDeltaTime ); + protected: BitmapText m_textDigits[MAX_SCORE_DIGITS]; + int iCurrentScoreDigits[MAX_SCORE_DIGITS]; + int iDestinationScoreDigits[MAX_SCORE_DIGITS]; + + float m_fTimeUntilNextTick; }; #endif \ No newline at end of file diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 2c491bc99b..14d90eff25 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -676,11 +676,19 @@ SOURCE=.\Rectangle.h # End Source File # Begin Source File -SOURCE=.\ScoreDisplay.cpp +SOURCE=.\ScoreDisplayFlipping.cpp # End Source File # Begin Source File -SOURCE=.\ScoreDisplay.h +SOURCE=.\ScoreDisplayFlipping.h +# End Source File +# Begin Source File + +SOURCE=.\ScoreDisplayRolling.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScoreDisplayRolling.h # End Source File # Begin Source File