add GetUndisplayedBeats
This commit is contained in:
Glenn Maynard
2003-09-23 23:56:15 +00:00
parent 03a778d642
commit a12b841a4f
3 changed files with 19 additions and 13 deletions
+16 -10
View File
@@ -551,7 +551,18 @@ void GameState::ResetNoteSkins()
}
/* From NoteField: */
extern float g_fNoteFieldLastBeatToDraw[NUM_PLAYERS];
void GameState::GetUndisplayedBeats( PlayerNumber pn, float TotalSeconds, float &StartBeat, float &EndBeat )
{
/* If reasonable, push the attack forward so notes on screen don't change suddenly. */
StartBeat = min( this->m_fSongBeat+BEATS_PER_MEASURE*2, m_fLastDrawnBeat[pn] );
StartBeat = truncf(StartBeat)+1;
const float StartSecond = this->m_pCurSong->GetElapsedTimeFromBeat( StartBeat );
const float EndSecond = StartSecond + TotalSeconds;
EndBeat = this->m_pCurSong->GetBeatFromElapsedTime( EndSecond );
EndBeat = truncf(EndBeat)+1;
}
void GameState::LaunchAttack( PlayerNumber target, Attack a )
{
@@ -574,13 +585,8 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a )
map<float,CString> &BeatToNoteSkin = m_BeatToNoteSkin[target];
/* Add it in the future, past what's currently on screen, so new arrows will scroll
* on screen with this skin. */
const float CurBeat = this->m_fSongBeat;
/* If reasonable, push the attack forward so notes on screen don't change suddenly. */
const float AddBeat = min( CurBeat+16, g_fNoteFieldLastBeatToDraw[target] );
const float AddSecond = this->m_pCurSong->GetElapsedTimeFromBeat( CurBeat );
const float EndSecond = AddSecond + a.fSecsRemaining;
const float EndBeat = this->m_pCurSong->GetBeatFromElapsedTime( EndSecond );
float StartBeat, EndBeat;
GetUndisplayedBeats( target, a.fSecsRemaining, StartBeat, EndBeat );
/* If there are any note skins after the point we're adding, remove them. We probably
* have overlapping note skin attacks. */
@@ -589,7 +595,7 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a )
{
map<float,CString>::iterator next = it;
++next;
if( it->first >= AddBeat )
if( it->first >= StartBeat )
{
LOG->Trace( "erase old %f", it->first );
BeatToNoteSkin.erase( it );
@@ -598,7 +604,7 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a )
}
/* Add the skin to m_BeatToNoteSkin. */
BeatToNoteSkin[AddBeat] = po.m_sNoteSkin;
BeatToNoteSkin[StartBeat] = po.m_sNoteSkin;
/* Return to the default note skin after the duration. */
BeatToNoteSkin[EndBeat] = GAMESTATE->m_PlayerOptions[target].m_sNoteSkin;
+2
View File
@@ -154,6 +154,7 @@ public:
float m_fCurBPS;
bool m_bFreeze; // in the middle of a freeze
bool m_bPastHereWeGo;
float m_fLastDrawnBeat[NUM_PLAYERS]; // set by NoteField
map<float,CString> m_BeatToNoteSkin[NUM_PLAYERS];
int m_BeatToNoteSkinRev; /* hack: incremented whenever m_BeatToNoteSkin changes */
@@ -192,6 +193,7 @@ public:
float m_fSuperMeter[NUM_PLAYERS]; // between 0 and NUM_ATTACK_LEVELS
bool m_bActiveAttackEndedThisUpdate[NUM_PLAYERS]; // flag for other objects to watch (play sounds)
void GetUndisplayedBeats( PlayerNumber pn, float TotalSeconds, float &StartBeat, float &EndBeat ); // only meaningful when a NoteField is in use
void LaunchAttack( PlayerNumber target, Attack aa );
void RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn );
void RemoveAllActiveAttacks() // called on end of song
+1 -3
View File
@@ -346,7 +346,6 @@ float FindLastDisplayedBeat( PlayerNumber pn, int iLastPixelToDraw )
return fLastBeatToDraw;
}
float g_fNoteFieldLastBeatToDraw[NUM_PLAYERS] = { -1, -1 };
void NoteField::DrawPrimitives()
{
@@ -376,8 +375,7 @@ void NoteField::DrawPrimitives()
float fFirstBeatToDraw = FindFirstDisplayedBeat( m_PlayerNumber, iFirstPixelToDraw );
float fLastBeatToDraw = FindLastDisplayedBeat( m_PlayerNumber, iLastPixelToDraw );
/* Hack: */
g_fNoteFieldLastBeatToDraw[m_PlayerNumber] = fLastBeatToDraw;
GAMESTATE->m_fLastDrawnBeat[m_PlayerNumber] = fLastBeatToDraw;
const int iFirstIndexToDraw = BeatToNoteRow(fFirstBeatToDraw);
const int iLastIndexToDraw = BeatToNoteRow(fLastBeatToDraw);