keep track of life
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <math.h>
|
||||
#include "RageMath.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
//
|
||||
@@ -431,6 +432,9 @@ void LifeMeterBar::Update( float fDeltaTime )
|
||||
{
|
||||
LifeMeter::Update( fDeltaTime );
|
||||
|
||||
GAMESTATE->m_CurStageStats.SetLifeRecord( m_PlayerNumber, m_fLifePercentage, GAMESTATE->m_fSongBeat / GAMESTATE->m_pCurSong->m_fLastBeat );
|
||||
|
||||
|
||||
// HACK: Tweaking these values is very difficulty. Update the
|
||||
// "physics" many times so that the spring motion appears faster
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
StageStats::StageStats()
|
||||
{
|
||||
memset( this, 0, sizeof(StageStats) );
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
for( int i = 0; i < LIFE_RECORD_RESOLUTION; ++i )
|
||||
fLifeRecord[p][i] = -1;
|
||||
}
|
||||
|
||||
void StageStats::AddStats( const StageStats& other )
|
||||
@@ -59,6 +62,9 @@ void StageStats::AddStats( const StageStats& other )
|
||||
iSongsPassed[p] += other.iSongsPassed[p];
|
||||
iSongsPlayed[p] += other.iSongsPlayed[p];
|
||||
iTotalError[p] += other.iTotalError[p];
|
||||
|
||||
for( int i = 0; i < LIFE_RECORD_RESOLUTION; ++i )
|
||||
fLifeRecord[p][i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,3 +152,20 @@ float StageStats::GetPercentDancePoints( PlayerNumber pn ) const
|
||||
float fPercentDancePoints = iActualDancePoints[pn] / (float)iPossibleDancePoints[pn];
|
||||
return clamp( fPercentDancePoints, 0, 1 );
|
||||
}
|
||||
|
||||
void StageStats::SetLifeRecord( PlayerNumber pn, float life, float pos )
|
||||
{
|
||||
int offset = (int) roundf( pos * LIFE_RECORD_RESOLUTION );
|
||||
for( int i = 0; i <= offset; ++i )
|
||||
if( fLifeRecord[pn][i] < 0 )
|
||||
fLifeRecord[pn][i] = life;
|
||||
}
|
||||
|
||||
void StageStats::GetLifeRecord( PlayerNumber pn, float *life, int nout ) const
|
||||
{
|
||||
for( int i = 0; i < nout; ++i )
|
||||
{
|
||||
int from = i * (LIFE_RECORD_RESOLUTION-1) / nout;
|
||||
life[i] = fLifeRecord[pn][from];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ struct StageStats
|
||||
int iSongsPassed[NUM_PLAYERS];
|
||||
int iSongsPlayed[NUM_PLAYERS];
|
||||
int iTotalError[NUM_PLAYERS];
|
||||
|
||||
enum { LIFE_RECORD_RESOLUTION=1000 };
|
||||
float fLifeRecord[NUM_PLAYERS][LIFE_RECORD_RESOLUTION];
|
||||
void SetLifeRecord( PlayerNumber pn, float life, float pos );
|
||||
void GetLifeRecord( PlayerNumber pn, float *life, int nout ) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user