Bring ticks in edit closer to gameplay; perhaps move this to Player to

get rid of the dupe ...
This commit is contained in:
Glenn Maynard
2002-10-18 01:09:59 +00:00
parent def5791975
commit 191d6aa8fd
2 changed files with 37 additions and 27 deletions
+33 -25
View File
@@ -317,6 +317,37 @@ ScreenEdit::~ScreenEdit()
m_soundMusic.Stop();
}
// play assist ticks
bool ScreenEdit::PlayTicks() const
{
// Sound cards have a latency between when a sample is Play()ed and when the sound
// will start coming out the speaker. Compensate for this by boosting
// fPositionSeconds ahead
if( GAMESTATE->m_SongOptions.m_AssistType != SongOptions::ASSIST_TICK )
return false;
float fPositionSeconds = GAMESTATE->m_fMusicSeconds;
float fSongBeat, fBPS;
bool bFreeze;
// HACK: Play the sound a little bit early to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing.
fPositionSeconds += (SOUND->GetPlayLatency()+0.018f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.015 seconds to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing.
GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze );
int iRowNow = BeatToNoteRowNotRounded( fSongBeat );
iRowNow = max( 0, iRowNow );
static int iRowLastCrossed = 0;
bool bAnyoneHasANote = false; // set this to true if any player has a note at one of the indicies we crossed
for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update
bAnyoneHasANote |= m_Player.IsThereANoteAtRow( r );
iRowLastCrossed = iRowNow;
return bAnyoneHasANote;
}
void ScreenEdit::Update( float fDeltaTime )
{
@@ -413,31 +444,8 @@ void ScreenEdit::Update( float fDeltaTime )
m_NoteFieldEdit.Update( fDeltaTime );
//
// play assist ticks
//
// Sound cards have a latency between when a sample is Play()ed and when the sound
// will start coming out the speaker. Compensate for this by boosting
// fPositionSeconds ahead
if( m_EditMode == MODE_PLAYING && GAMESTATE->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK )
{
fPositionSeconds += (SOUND->GetPlayLatency()+0.018f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.015 seconds to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing.
GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze );
int iRowNow = BeatToNoteRowNotRounded( fSongBeat );
iRowNow = max( 0, iRowNow );
static int iRowLastCrossed = 0;
bool bAnyoneHasANote = false; // set this to true if any player has a note at one of the indicies we crossed
for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update
bAnyoneHasANote |= m_Player.IsThereANoteAtRow( r );
if( bAnyoneHasANote )
m_soundAssistTick.Play();
iRowLastCrossed = iRowNow;
}
if(m_EditMode == MODE_PLAYING && PlayTicks())
m_soundAssistTick.Play();
+4 -2
View File
@@ -40,10 +40,12 @@ public:
void InputRecord( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
void InputPlay( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleScreenMessage( const ScreenMessage SM );
void TransitionFromRecordToEdit();
void TransitionToEdit();
protected:
void TransitionFromRecordToEdit();
void TransitionToEdit();
bool PlayTicks() const;
void OnSnapModeChange();
void MenuItemGainFocus( BitmapText* menuitem );
void MenuItemLoseFocus( BitmapText* menuitem );