NEW FEATURE: Animated score while dancing
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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; i<MAX_SCORE_DIGITS; i++ )
|
||||
{
|
||||
m_textDigits[i].Load( THEME->GetPathTo(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; i<MAX_SCORE_DIGITS; i++ )
|
||||
{
|
||||
m_textDigits[i].SetText( sScore[i] );
|
||||
|
||||
m_textDigits[i].StopTweening();
|
||||
m_textDigits[i].SetZoomX( 0 );
|
||||
m_textDigits[i].BeginTweeningQueued( 0.2f * (MAX_SCORE_DIGITS-i) / MAX_SCORE_DIGITS + 0.1f );
|
||||
// do nothing - this tween is a wait
|
||||
m_textDigits[i].BeginTweeningQueued( 0.2f );
|
||||
m_textDigits[i].SetTweenZoomX( 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "stdafx.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File: ScoreDisplayRolling.h
|
||||
|
||||
Desc: A graphic displayed in the ScoreDisplayRolling during Dancing.
|
||||
|
||||
Copyright (c) 2001 Chris Danford. All rights reserved.
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "ScoreDisplayRolling.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ThemeManager.h"
|
||||
|
||||
|
||||
const float TIME_BETWEEN_TICKS = 0.05f;
|
||||
|
||||
ScoreDisplayRolling::ScoreDisplayRolling()
|
||||
{
|
||||
RageLog( "ScoreDisplayRolling::ScoreDisplayRolling()" );
|
||||
|
||||
for( int i=0; i<MAX_SCORE_DIGITS; i++ )
|
||||
{
|
||||
m_textDigits[i].Load( THEME->GetPathTo(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<MAX_SCORE_DIGITS; i++ )
|
||||
{
|
||||
iDestinationScoreDigits[i] = atoi( sScore.Mid(i,1) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ScoreDisplayRolling::Update( float fDeltaTime )
|
||||
{
|
||||
ActorFrame::Update( fDeltaTime );
|
||||
|
||||
m_fTimeUntilNextTick -= fDeltaTime;
|
||||
|
||||
while( m_fTimeUntilNextTick <= 0 )
|
||||
{
|
||||
m_fTimeUntilNextTick += TIME_BETWEEN_TICKS;
|
||||
|
||||
// do a tick
|
||||
for( int i=0; i<MAX_SCORE_DIGITS; i++ )
|
||||
{
|
||||
if( iCurrentScoreDigits[i] != iDestinationScoreDigits[i] )
|
||||
{
|
||||
iCurrentScoreDigits[i]++;
|
||||
if( iCurrentScoreDigits[i] > 9 )
|
||||
iCurrentScoreDigits[i] = 0;
|
||||
|
||||
m_textDigits[i].SetText( ssprintf("%d", iCurrentScoreDigits[i]) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user