Move the BeginnerHelper code from ScreenGameplay::Update() into BeginnerHelper::Update()

This commit is contained in:
Thad Ward
2003-08-25 06:20:44 +00:00
parent cf23c9c14c
commit 5c5c4ed329
4 changed files with 47 additions and 37 deletions
+37 -4
View File
@@ -28,6 +28,7 @@ BeginnerHelper::BeginnerHelper()
{
LOG->Trace("BeginnerHelper::BeginnerHelper()");
m_bFlashEnabled = false;
m_bInitialized = false;
this->AddChild(&m_sBackground);
this->AddChild(&m_sFlash);
}
@@ -66,8 +67,11 @@ void BeginnerHelper::SetFlash( CString sFilename, float fX, float fY )
m_sFlash.SetY(fY);
}
void BeginnerHelper::Initialize( int iDancePadType )
void BeginnerHelper::Initialize( int iDancePadType, NoteData *pNotes )
{
// Copy the note data from our caller.
m_NoteData.CopyAll(pNotes);
// Load the StepCircle, Background, and flash animation
m_sBackground.Load( THEME->GetPathToG("BeginnerHelper background") );
m_sBackground.SetXY( CENTER_X, CENTER_Y);
@@ -130,6 +134,8 @@ void BeginnerHelper::Initialize( int iDancePadType )
this->AddChild( &m_mDancer[pl] );
}
}
m_bInitialized = true;
}
void BeginnerHelper::FlashOnce()
@@ -143,6 +149,9 @@ void BeginnerHelper::FlashOnce()
void BeginnerHelper::DrawPrimitives()
{
if(!m_bInitialized)
return;
m_sBackground.Draw();
m_sFlash.Draw();
@@ -202,10 +211,34 @@ void BeginnerHelper::Step( int CSTEP )
void BeginnerHelper::Update( float fDeltaTime )
{
m_sFlash.Update(fDeltaTime);
if(!m_bInitialized)
return;
float beat = fDeltaTime * GAMESTATE->m_fCurBPS;
m_sFlash.Update( beat );
for( int scu=0; scu<NUM_PLAYERS*2; scu++ )
m_sStepCircle[scu].Update(fDeltaTime);
m_sStepCircle[scu].Update( beat );
for( int pu=0; pu<NUM_PLAYERS; pu++ )
m_mDancer[pu].Update( fDeltaTime ); //Update dancers
m_mDancer[pu].Update( beat ); //Update dancers
int iStep = 0;
if( (m_NoteData.IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.1f)) ) ) )
FlashOnce();
if((m_NoteData.IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.45f)))))
{
for( int k=0; k<m_NoteData.GetNumTracks(); k++ )
if( m_NoteData.GetTapNote(k, BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.45f)) ) == TAP_TAP )
{
switch(k)
{
case 0: iStep += 6; break;
case 1: iStep += 3; break;
case 2: iStep += 8; break;
case 3: iStep += 4; break;
};
}
Step( iStep );
}
}
+4 -1
View File
@@ -6,6 +6,7 @@
#include "Character.h"
#include "Sprite.h"
#include "PlayerNumber.h"
#include "NoteData.h"
class BeginnerHelper : public ActorFrame
{
@@ -26,7 +27,7 @@ public:
ActorFrame m_afDancerSuite; // So we can easily rotate or whatever without disturbing the Background.
void FlashOnce();
void Initialize( int iDancePadType );
void Initialize( int iDancePadType, NoteData *pNotes );
void SetFlash(CString sFilename, float fX, float fY);
void ShowStepCircle( int CSTEP );
void Step( int CSTEP );
@@ -37,6 +38,7 @@ public:
virtual void DrawPrimitives();
protected:
NoteData m_NoteData;
Model m_mDancer[NUM_PLAYERS];
Model m_mDancePad;
Sprite m_sFlash;
@@ -44,6 +46,7 @@ protected:
Sprite m_sStepCircle[NUM_PLAYERS*2]; // Need two for each player during jumps
int iDancePadType; // 0=none, 1=single, 2=double || This entire class only uses 1 pad.
bool m_bInitialized;
bool m_bFlashEnabled;
};
#endif
+6 -31
View File
@@ -777,19 +777,19 @@ void ScreenGameplay::LoadNextSong()
// Beginner steps are always the same on both players.. Just get the # of 1 player that's using the Beginner steps, and go on.
m_iPOB = -1;
int pn = -1;
for( int pb=0; pb<NUM_PLAYERS; pb++ )
if( GAMESTATE->IsPlayerEnabled(pb) && GAMESTATE->m_PreferredDifficulty[pb] == DIFFICULTY_BEGINNER )
m_iPOB = pb;
pn = pb;
/* TODO: fall back on m_Background if nobody is on beginner. */
if( PREFSMAN->m_bShowBeginnerHelper && m_iPOB != -1)
if( PREFSMAN->m_bShowBeginnerHelper && pn != -1)
{
m_Background.Unload(); // BeginnerHelper has it's own BG control.
m_Background.StopAnimating();
//m_BeginnerHelper.m_bEnabled = true; // Not yet implemented
m_BeginnerHelper.Initialize( 2 ); // Init for doubles
m_BeginnerHelper.Initialize( 2, &m_Player[pn] ); // Init for doubles
m_BeginnerHelper.SetX( CENTER_X );
m_BeginnerHelper.SetY( CENTER_Y );
}
@@ -983,37 +983,12 @@ void ScreenGameplay::Update( float fDeltaTime )
//LOG->Trace( "m_fOffsetInBeats = %f, m_fBeatsPerSecond = %f, m_Music.GetPositionSeconds = %f", m_fOffsetInBeats, m_fBeatsPerSecond, m_Music.GetPositionSeconds() );
int pn;
/* Why *GAMESTATE->m_fCurBPS? Update() functions are usually seconds; this will
* make time units within BeginnerHelper actors odd. */
m_BeginnerHelper.Update(fDeltaTime*GAMESTATE->m_fCurBPS);
m_BeginnerHelper.Update(fDeltaTime);
switch( m_DancingState )
{
case STATE_DANCING:
// Check to see what we animate on this one
/* tip: Store a NoteData inside BeginnerHelper, Load it above and handle all of this
* within BeginnerHelper::Update. */
if( PREFSMAN->m_bShowBeginnerHelper && m_iPOB != -1)
{
int iStep = 0;
if( (m_Player[m_iPOB].IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.1f)) ) ) )
m_BeginnerHelper.FlashOnce();
if((m_Player[m_iPOB].IsThereATapAtRow( BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.45f)))))
{
for( int k=0; k<m_Player[m_iPOB].GetNumTracks(); k++ )
if( m_Player[m_iPOB].GetTapNote(k, BeatToNoteRowNotRounded((GAMESTATE->m_fSongBeat+0.45f)) ) == TAP_TAP )
{
switch(k)
{
case 0: iStep += 6; break;
case 1: iStep += 3; break;
case 2: iStep += 8; break;
case 3: iStep += 4; break;
};
}
m_BeginnerHelper.Step( iStep );
}
}
// Check to see what we animate on this one
// -------------------------------------------
-1
View File
@@ -187,7 +187,6 @@ protected:
RageSound m_soundMusic;
BeginnerHelper m_BeginnerHelper;
int m_iPOB; // Number of any player on Beginner.. Used for step-sensing
};