handle C* scroll speeds when drawing the board
This commit is contained in:
+40
-12
@@ -39,6 +39,11 @@ NoteField::NoteField()
|
|||||||
m_sprBoard.Load( THEME->GetPathG("NoteField","board") );
|
m_sprBoard.Load( THEME->GetPathG("NoteField","board") );
|
||||||
m_sprBoard.StopAnimating();
|
m_sprBoard.StopAnimating();
|
||||||
|
|
||||||
|
m_fBoardOffsetPixels = 0;
|
||||||
|
m_fCurrentBeatLastUpdate = -1;
|
||||||
|
m_fYPosCurrentBeatLastUpdate = -1;
|
||||||
|
this->SubscribeToMessage( Message_CurrentSongChanged );
|
||||||
|
|
||||||
m_sprBeatBars.Load( THEME->GetPathG("NoteField","bars") );
|
m_sprBeatBars.Load( THEME->GetPathG("NoteField","bars") );
|
||||||
m_sprBeatBars.StopAnimating();
|
m_sprBeatBars.StopAnimating();
|
||||||
|
|
||||||
@@ -173,6 +178,26 @@ void NoteField::Update( float fDeltaTime )
|
|||||||
{
|
{
|
||||||
ActorFrame::Update( fDeltaTime );
|
ActorFrame::Update( fDeltaTime );
|
||||||
|
|
||||||
|
m_sprBoard.Update( fDeltaTime );
|
||||||
|
|
||||||
|
// update m_fBoardOffsetPixels, m_fCurrentBeatLastUpdate, m_fYPosCurrentBeatLastUpdate
|
||||||
|
const float fCurrentBeat = GAMESTATE->m_fSongBeat;
|
||||||
|
if( m_fCurrentBeatLastUpdate != -1 )
|
||||||
|
{
|
||||||
|
const float fYOffsetLast = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate );
|
||||||
|
const float fYPosLast = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetLast, m_fYReverseOffsetPixels );
|
||||||
|
const float fPixelDifference = fYPosLast - m_fYPosCurrentBeatLastUpdate;
|
||||||
|
|
||||||
|
//LOG->Trace( "speed = %f, %f, %f, %f, %f, %f", fSpeed, fYOffsetAtCurrent, fYOffsetAtNext, fSecondsAtCurrent, fSecondsAtNext, fPixelDifference, fSecondsDifference );
|
||||||
|
|
||||||
|
m_fBoardOffsetPixels += fPixelDifference;
|
||||||
|
wrap( m_fBoardOffsetPixels, m_sprBoard.GetUnzoomedHeight() );
|
||||||
|
}
|
||||||
|
m_fCurrentBeatLastUpdate = fCurrentBeat;
|
||||||
|
const float fYOffsetCurrent = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate );
|
||||||
|
m_fYPosCurrentBeatLastUpdate = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetCurrent, m_fYReverseOffsetPixels );
|
||||||
|
|
||||||
|
|
||||||
m_rectMarkerBar.Update( fDeltaTime );
|
m_rectMarkerBar.Update( fDeltaTime );
|
||||||
|
|
||||||
NoteDisplayCols *cur = m_pCurDisplay;
|
NoteDisplayCols *cur = m_pCurDisplay;
|
||||||
@@ -278,38 +303,29 @@ void NoteField::DrawBeatBar( const float fBeat )
|
|||||||
|
|
||||||
void NoteField::DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels )
|
void NoteField::DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels )
|
||||||
{
|
{
|
||||||
const float fYOffsetAt0 = ArrowEffects::GetYOffset( m_pPlayerState, 0, GAMESTATE->m_fSongBeat );
|
const float fYPosAt0 = ArrowEffects::GetYPos( m_pPlayerState, 0, 0, m_fYReverseOffsetPixels );
|
||||||
const float fYOffsetAtNeg1 = ArrowEffects::GetYOffset( m_pPlayerState, 0, GAMESTATE->m_fSongBeat-1 );
|
|
||||||
const float fYPosAt0 = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetAt0, m_fYReverseOffsetPixels );
|
|
||||||
const float fYPosAtNeg1 = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetAtNeg1, m_fYReverseOffsetPixels );
|
|
||||||
const float fBeatSpacingPixels = fYPosAtNeg1 - fYPosAt0;
|
|
||||||
|
|
||||||
float fBeat = GAMESTATE->m_fSongBeat;
|
|
||||||
float fPixels = fBeat * fBeatSpacingPixels;
|
|
||||||
|
|
||||||
// Draw the board centered on fYPosAt0 so that the board doesn't slide as the draw distance changes with modifiers.
|
// Draw the board centered on fYPosAt0 so that the board doesn't slide as the draw distance changes with modifiers.
|
||||||
|
|
||||||
m_sprBoard.SetY( fYPosAt0 );
|
m_sprBoard.SetY( fYPosAt0 );
|
||||||
RectF rect = *m_sprBoard.GetCurrentTextureCoordRect();
|
RectF rect = *m_sprBoard.GetCurrentTextureCoordRect();
|
||||||
const float fBoardGraphicHeightPixels = m_sprBoard.GetUnzoomedHeight();
|
const float fBoardGraphicHeightPixels = m_sprBoard.GetUnzoomedHeight();
|
||||||
float fTexCoordOffset = fPixels / fBoardGraphicHeightPixels;
|
float fTexCoordOffset = m_fBoardOffsetPixels / fBoardGraphicHeightPixels;
|
||||||
{
|
{
|
||||||
// top half
|
// top half
|
||||||
const float fHeight = iDrawDistanceBeforeTargetsPixels;
|
const float fHeight = iDrawDistanceBeforeTargetsPixels;
|
||||||
m_sprBoard.ZoomToHeight( fHeight );
|
m_sprBoard.ZoomToHeight( fHeight );
|
||||||
wrap( fPixels, fHeight );
|
|
||||||
|
|
||||||
rect.top = -fTexCoordOffset-(fHeight/fBoardGraphicHeightPixels);
|
rect.top = -fTexCoordOffset-(fHeight/fBoardGraphicHeightPixels);
|
||||||
rect.bottom = -fTexCoordOffset;
|
rect.bottom = -fTexCoordOffset;
|
||||||
m_sprBoard.SetCustomTextureRect( rect );
|
m_sprBoard.SetCustomTextureRect( rect );
|
||||||
m_sprBoard.SetVertAlign( VertAlign_Bottom );
|
m_sprBoard.SetVertAlign( VertAlign_Bottom );
|
||||||
m_sprBoard.SetFadeTop( 0.2f );
|
m_sprBoard.SetFadeTop( FADE_BEFORE_TARGETS_PERCENT );
|
||||||
m_sprBoard.Draw();
|
m_sprBoard.Draw();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const float fHeight = -iDrawDistanceAfterTargetsPixels;
|
const float fHeight = -iDrawDistanceAfterTargetsPixels;
|
||||||
m_sprBoard.ZoomToHeight( fHeight );
|
m_sprBoard.ZoomToHeight( fHeight );
|
||||||
wrap( fPixels, fHeight );
|
|
||||||
|
|
||||||
rect.top = -fTexCoordOffset;
|
rect.top = -fTexCoordOffset;
|
||||||
rect.bottom = -fTexCoordOffset+(fHeight/fBoardGraphicHeightPixels);
|
rect.bottom = -fTexCoordOffset+(fHeight/fBoardGraphicHeightPixels);
|
||||||
@@ -875,6 +891,18 @@ void NoteField::Step( int iCol, TapNoteScore score ) { m_pCurDisplay->m_Receptor
|
|||||||
void NoteField::SetPressed( int iCol ) { m_pCurDisplay->m_ReceptorArrowRow.SetPressed( iCol ); }
|
void NoteField::SetPressed( int iCol ) { m_pCurDisplay->m_ReceptorArrowRow.SetPressed( iCol ); }
|
||||||
void NoteField::DidTapNote( int iCol, TapNoteScore score, bool bBright ) { m_pCurDisplay->m_GhostArrowRow.DidTapNote( iCol, score, bBright ); }
|
void NoteField::DidTapNote( int iCol, TapNoteScore score, bool bBright ) { m_pCurDisplay->m_GhostArrowRow.DidTapNote( iCol, score, bBright ); }
|
||||||
void NoteField::DidHoldNote( int iCol, HoldNoteScore score, bool bBright ) { m_pCurDisplay->m_GhostArrowRow.DidHoldNote( iCol, score, bBright ); }
|
void NoteField::DidHoldNote( int iCol, HoldNoteScore score, bool bBright ) { m_pCurDisplay->m_GhostArrowRow.DidHoldNote( iCol, score, bBright ); }
|
||||||
|
|
||||||
|
void NoteField::HandleMessage( const Message &msg )
|
||||||
|
{
|
||||||
|
if( msg == Message_CurrentSongChanged )
|
||||||
|
{
|
||||||
|
m_fCurrentBeatLastUpdate = -1;
|
||||||
|
m_fYPosCurrentBeatLastUpdate = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActorFrame::HandleMessage( msg );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Chris Danford
|
* (c) 2001-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public:
|
|||||||
int iDrawDistanceBeforeTargetsPixels );
|
int iDrawDistanceBeforeTargetsPixels );
|
||||||
virtual void Unload();
|
virtual void Unload();
|
||||||
|
|
||||||
|
virtual void HandleMessage( const Message &msg );
|
||||||
|
|
||||||
// This is done automatically by Init(), but can be re-called explicitly if the
|
// This is done automatically by Init(), but can be re-called explicitly if the
|
||||||
// note skin changes.
|
// note skin changes.
|
||||||
void CacheAllUsedNoteSkins();
|
void CacheAllUsedNoteSkins();
|
||||||
@@ -86,6 +88,10 @@ protected:
|
|||||||
|
|
||||||
// decorations, mostly used in MODE_EDIT
|
// decorations, mostly used in MODE_EDIT
|
||||||
Sprite m_sprBoard;
|
Sprite m_sprBoard;
|
||||||
|
float m_fBoardOffsetPixels;
|
||||||
|
float m_fCurrentBeatLastUpdate; // -1 on first update
|
||||||
|
float m_fYPosCurrentBeatLastUpdate; // -1 on first update
|
||||||
|
|
||||||
Sprite m_sprBeatBars; // 4 frames: Measure, 4th, 8th, 16th
|
Sprite m_sprBeatBars; // 4 frames: Measure, 4th, 8th, 16th
|
||||||
BitmapText m_textMeasureNumber;
|
BitmapText m_textMeasureNumber;
|
||||||
Quad m_rectMarkerBar;
|
Quad m_rectMarkerBar;
|
||||||
|
|||||||
Reference in New Issue
Block a user