This commit is contained in:
Steve Checkoway
2006-07-16 07:20:50 +00:00
parent 2e3f9bc82b
commit ad1e7b4afa
+117 -115
View File
@@ -51,9 +51,9 @@ static const char *anims[NUM_ANIMATIONS] =
"BeginnerHelper_step-jumplr.bones.txt"
};
static RString GetAnimPath(Animation a)
static RString GetAnimPath( Animation a )
{
return RString("Characters/") + anims[a];
return RString( "Characters/" ) + anims[a];
}
BeginnerHelper::BeginnerHelper()
@@ -87,35 +87,35 @@ void BeginnerHelper::ShowStepCircle( PlayerNumber pn, int CSTEP )
}
m_sStepCircle[pn][isc].StopEffect();
m_sStepCircle[pn][isc].SetZoom(2);
m_sStepCircle[pn][isc].SetZoom( 2 );
m_sStepCircle[pn][isc].StopTweening();
m_sStepCircle[pn][isc].BeginTweening((GAMESTATE->m_fCurBPS/3), TWEEN_LINEAR);
m_sStepCircle[pn][isc].SetZoom(0);
m_sStepCircle[pn][isc].BeginTweening( GAMESTATE->m_fCurBPS/3, TWEEN_LINEAR );
m_sStepCircle[pn][isc].SetZoom( 0 );
}
void BeginnerHelper::AddPlayer( PlayerNumber pn, NoteData *pSteps )
{
ASSERT(!m_bInitialized);
ASSERT(pSteps != NULL);
ASSERT((pn >= 0) && (pn < NUM_PLAYERS));
ASSERT(GAMESTATE->IsHumanPlayer(pn));
ASSERT( !m_bInitialized );
ASSERT( pSteps != NULL );
ASSERT( pn >= 0 && pn < NUM_PLAYERS );
ASSERT( GAMESTATE->IsHumanPlayer(pn) );
if(!CanUse())
if( !CanUse() )
return;
const Character *Character = GAMESTATE->m_pCurCharacters[pn];
ASSERT( Character != NULL );
if(!DoesFileExist(Character->GetModelPath()))
if( !DoesFileExist(Character->GetModelPath()) )
return;
m_NoteData[pn].CopyAll(*pSteps);
m_NoteData[pn].CopyAll( *pSteps );
m_bPlayerEnabled[pn] = true;
}
bool BeginnerHelper::CanUse()
{
for(int i=0; i<NUM_ANIMATIONS; ++i)
if(!DoesFileExist(GetAnimPath((Animation)i)))
for (int i=0; i<NUM_ANIMATIONS; ++i )
if( !DoesFileExist(GetAnimPath((Animation)i)) )
return false;
return GAMESTATE->m_pCurStyle->m_bCanUseBeginnerHelper;
@@ -124,67 +124,69 @@ bool BeginnerHelper::CanUse()
bool BeginnerHelper::Initialize( int iDancePadType )
{
ASSERT( !m_bInitialized );
if(!CanUse())
if( !CanUse() )
return false;
// If no players were successfully added, bail.
{
bool bAnyLoaded = false;
for(int pn=0; pn<NUM_PLAYERS; pn++)
if(m_bPlayerEnabled[pn])
for( int pn=0; pn<NUM_PLAYERS; pn++ )
if( m_bPlayerEnabled[pn] )
bAnyLoaded = true;
if(!bAnyLoaded)
if( !bAnyLoaded )
return false;
}
// Load the Background and flash.. Flash only shows if the BG does.
if(m_bShowBackground)
if( m_bShowBackground )
{
m_sBackground.Load( THEME->GetPathG("BeginnerHelper","background") );
this->AddChild(&m_sBackground);
m_sBackground.SetXY(1,1);
m_sFlash.Load(THEME->GetPathG("BeginnerHelper","flash"));
m_sFlash.SetXY(0,0);
m_sFlash.SetDiffuseAlpha(0);
this->AddChild( &m_sBackground );
m_sBackground.SetXY( 1, 1 );
m_sFlash.Load( THEME->GetPathG("BeginnerHelper","flash") );
m_sFlash.SetXY( 0, 0 );
m_sFlash.SetDiffuseAlpha( 0 );
}
// Load StepCircle graphics
for(int lsc=0; lsc<NUM_PLAYERS; lsc++)
for(int lsce=0; lsce<4; lsce++)
for( int lsc=0; lsc<NUM_PLAYERS; lsc++ )
{
for( int lsce=0; lsce<4; lsce++ )
{
m_sStepCircle[lsc][lsce].Load(THEME->GetPathG("BeginnerHelper","stepcircle"));
m_sStepCircle[lsc][lsce].SetZoom(0); // Hide until needed.
m_sStepCircle[lsc][lsce].Load( THEME->GetPathG("BeginnerHelper","stepcircle") );
m_sStepCircle[lsc][lsce].SetZoom( 0 ); // Hide until needed.
this->AddChild(&m_sStepCircle[lsc][lsce]);
// Set coordinates of StepCircle
switch(lsce)
switch( lsce )
{
case 0: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)-80),HELPER_Y); break; // Left
case 1: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)+80),HELPER_Y); break; // Right
case 2: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)),(HELPER_Y-60)); break; // Up
case 3: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)),(HELPER_Y+60)); break; // Down
case 0: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)-80),HELPER_Y); break; // Left
case 1: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)+80),HELPER_Y); break; // Right
case 2: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)),(HELPER_Y-60)); break; // Up
case 3: m_sStepCircle[lsc][lsce].SetXY((HELPER_X+PLAYER_X(lsc)),(HELPER_Y+60)); break; // Down
}
}
}
// Load the DancePad
switch(iDancePadType)
switch( iDancePadType )
{
case 0: break; // No pad
case 1: m_pDancePad->LoadMilkshapeAscii(GetAnimPath(ANIM_DANCE_PAD)); break;
case 2: m_pDancePad->LoadMilkshapeAscii(GetAnimPath(ANIM_DANCE_PADS)); break;
case 0: break; // No pad
case 1: m_pDancePad->LoadMilkshapeAscii(GetAnimPath(ANIM_DANCE_PAD)); break;
case 2: m_pDancePad->LoadMilkshapeAscii(GetAnimPath(ANIM_DANCE_PADS)); break;
}
m_pDancePad->SetHorizAlign( align_left );
m_pDancePad->SetRotationX( DANCEPAD_ANGLE );
m_pDancePad->SetX(HELPER_X);
m_pDancePad->SetY(HELPER_Y);
m_pDancePad->SetZoom(23); // Pad should always be 3 units bigger in zoom than the dancer.
m_pDancePad->SetX( HELPER_X );
m_pDancePad->SetY( HELPER_Y );
m_pDancePad->SetZoom( 23 ); // Pad should always be 3 units bigger in zoom than the dancer.
for( int pl=0; pl<NUM_PLAYERS; pl++ ) // Load players
{
// Skip if not enabled
if(!m_bPlayerEnabled[pl])
if( !m_bPlayerEnabled[pl] )
continue;
// Load character data
@@ -196,20 +198,20 @@ bool BeginnerHelper::Initialize( int iDancePadType )
m_pDancer[pl]->LoadMilkshapeAscii( Character->GetModelPath() );
// Load needed animations
m_pDancer[pl]->LoadMilkshapeAsciiBones("Step-LEFT", GetAnimPath(ANIM_LEFT));
m_pDancer[pl]->LoadMilkshapeAsciiBones("Step-DOWN", GetAnimPath(ANIM_DOWN));
m_pDancer[pl]->LoadMilkshapeAsciiBones("Step-UP", GetAnimPath(ANIM_UP));
m_pDancer[pl]->LoadMilkshapeAsciiBones("Step-RIGHT", GetAnimPath(ANIM_RIGHT));
m_pDancer[pl]->LoadMilkshapeAsciiBones("Step-JUMPLR", GetAnimPath(ANIM_JUMPLR));
m_pDancer[pl]->LoadMilkshapeAsciiBones("rest", Character->GetRestAnimationPath());
m_pDancer[pl]->SetDefaultAnimation("rest");
m_pDancer[pl]->PlayAnimation("rest");
m_pDancer[pl]->SetRotationX(PLAYER_ANGLE);
m_pDancer[pl]->SetX(HELPER_X+PLAYER_X(pl));
m_pDancer[pl]->SetY(HELPER_Y+10);
m_pDancer[pl]->SetZoom(20);
m_pDancer[pl]->SetCullMode(CULL_NONE); // many of the models floating around have the vertex order flipped
m_pDancer[pl]->m_bRevertToDefaultAnimation = true; // Stay bouncing after a step has finished animating
m_pDancer[pl]->LoadMilkshapeAsciiBones( "Step-LEFT", GetAnimPath(ANIM_LEFT) );
m_pDancer[pl]->LoadMilkshapeAsciiBones( "Step-DOWN", GetAnimPath(ANIM_DOWN) );
m_pDancer[pl]->LoadMilkshapeAsciiBones( "Step-UP", GetAnimPath(ANIM_UP) );
m_pDancer[pl]->LoadMilkshapeAsciiBones( "Step-RIGHT", GetAnimPath(ANIM_RIGHT) );
m_pDancer[pl]->LoadMilkshapeAsciiBones( "Step-JUMPLR", GetAnimPath(ANIM_JUMPLR) );
m_pDancer[pl]->LoadMilkshapeAsciiBones(" rest", Character->GetRestAnimationPath() );
m_pDancer[pl]->SetDefaultAnimation( "rest" );
m_pDancer[pl]->PlayAnimation( "rest" );
m_pDancer[pl]->SetRotationX( PLAYER_ANGLE );
m_pDancer[pl]->SetX( HELPER_X+PLAYER_X(pl) );
m_pDancer[pl]->SetY( HELPER_Y+10 );
m_pDancer[pl]->SetZoom( 20 );
m_pDancer[pl]->SetCullMode( CULL_NONE ); // many of the models floating around have the vertex order flipped
m_pDancer[pl]->m_bRevertToDefaultAnimation = true; // Stay bouncing after a step has finished animating
}
m_bInitialized = true;
@@ -219,14 +221,14 @@ bool BeginnerHelper::Initialize( int iDancePadType )
void BeginnerHelper::DrawPrimitives()
{
// If not initialized, don't bother with this
if(!m_bInitialized)
if( !m_bInitialized )
return;
ActorFrame::DrawPrimitives();
m_sFlash.Draw();
bool DrawCelShaded = PREFSMAN->m_bCelShadeModels;
if(DrawCelShaded)
if( DrawCelShaded )
m_pDancePad->DrawCelShaded();
else
{
@@ -240,8 +242,8 @@ void BeginnerHelper::DrawPrimitives()
m_pDancePad->Draw();
DISPLAY->ClearZBuffer(); // So character doesn't step "into" the dance pad.
DISPLAY->SetLightOff(0);
DISPLAY->SetLighting(false);
DISPLAY->SetLightOff( 0 );
DISPLAY->SetLighting( false );
}
// Draw StepCircles
@@ -249,9 +251,9 @@ void BeginnerHelper::DrawPrimitives()
for(int scde=0; scde<4; scde++)
m_sStepCircle[scd][scde].Draw();
if(DrawCelShaded)
FOREACH_PlayerNumber(pn) // Draw each dancer
if(GAMESTATE->IsHumanPlayer(pn))
if( DrawCelShaded )
FOREACH_PlayerNumber( pn ) // Draw each dancer
if( GAMESTATE->IsHumanPlayer(pn) )
m_pDancer[pn]->DrawCelShaded();
else
{
@@ -263,77 +265,77 @@ void BeginnerHelper::DrawPrimitives()
RageColor(0,0,0,1),
RageVector3(0, 0, 1) );
FOREACH_PlayerNumber(pn) // Draw each dancer
if(GAMESTATE->IsHumanPlayer(pn))
FOREACH_PlayerNumber( pn ) // Draw each dancer
if( GAMESTATE->IsHumanPlayer(pn) )
m_pDancer[pn]->Draw();
DISPLAY->SetLightOff(0);
DISPLAY->SetLighting(false);
DISPLAY->SetLightOff( 0 );
DISPLAY->SetLighting( false );
}
}
void BeginnerHelper::Step( PlayerNumber pn, int CSTEP )
{
m_pDancer[pn]->StopTweening();
m_pDancer[pn]->SetRotationY(0); // Make sure we're not still inside of a JUMPUD tween.
m_pDancer[pn]->SetRotationY( 0 ); // Make sure we're not still inside of a JUMPUD tween.
switch(CSTEP)
{
case ST_LEFT:
ShowStepCircle(pn, ST_LEFT);
m_pDancer[pn]->PlayAnimation("Step-LEFT", 1.5f);
break;
case ST_RIGHT:
ShowStepCircle(pn, ST_RIGHT);
m_pDancer[pn]->PlayAnimation("Step-RIGHT", 1.5f);
break;
case ST_UP:
ShowStepCircle(pn, ST_UP);
m_pDancer[pn]->PlayAnimation("Step-UP", 1.5f);
break;
case ST_DOWN:
ShowStepCircle(pn, ST_DOWN);
m_pDancer[pn]->PlayAnimation("Step-DOWN", 1.5f);
break;
case ST_JUMPLR:
ShowStepCircle(pn, ST_LEFT);
ShowStepCircle(pn, ST_RIGHT);
m_pDancer[pn]->PlayAnimation("Step-JUMPLR", 1.5f);
break;
case ST_JUMPUD:
ShowStepCircle(pn, ST_UP);
ShowStepCircle(pn, ST_DOWN);
m_pDancer[pn]->StopTweening();
m_pDancer[pn]->PlayAnimation("Step-JUMPLR", 1.5f);
m_pDancer[pn]->BeginTweening((GAMESTATE->m_fCurBPS /8), TWEEN_LINEAR);
m_pDancer[pn]->SetRotationY(90);
m_pDancer[pn]->BeginTweening((1/(GAMESTATE->m_fCurBPS * 2))); //sleep between jump-frames
m_pDancer[pn]->BeginTweening(GAMESTATE->m_fCurBPS /6, TWEEN_LINEAR);
m_pDancer[pn]->SetRotationY(0);
break;
case ST_LEFT:
ShowStepCircle( pn, ST_LEFT );
m_pDancer[pn]->PlayAnimation( "Step-LEFT", 1.5f );
break;
case ST_RIGHT:
ShowStepCircle( pn, ST_RIGHT );
m_pDancer[pn]->PlayAnimation( "Step-RIGHT", 1.5f );
break;
case ST_UP:
ShowStepCircle( pn, ST_UP );
m_pDancer[pn]->PlayAnimation( "Step-UP", 1.5f );
break;
case ST_DOWN:
ShowStepCircle( pn, ST_DOWN );
m_pDancer[pn]->PlayAnimation( "Step-DOWN", 1.5f );
break;
case ST_JUMPLR:
ShowStepCircle( pn, ST_LEFT );
ShowStepCircle( pn, ST_RIGHT );
m_pDancer[pn]->PlayAnimation( "Step-JUMPLR", 1.5f );
break;
case ST_JUMPUD:
ShowStepCircle( pn, ST_UP );
ShowStepCircle( pn, ST_DOWN );
m_pDancer[pn]->StopTweening();
m_pDancer[pn]->PlayAnimation( "Step-JUMPLR", 1.5f );
m_pDancer[pn]->BeginTweening( GAMESTATE->m_fCurBPS/8, TWEEN_LINEAR );
m_pDancer[pn]->SetRotationY( 90 );
m_pDancer[pn]->BeginTweening( 1/(GAMESTATE->m_fCurBPS * 2) ); //sleep between jump-frames
m_pDancer[pn]->BeginTweening( GAMESTATE->m_fCurBPS /6, TWEEN_LINEAR );
m_pDancer[pn]->SetRotationY( 0 );
break;
}
m_sFlash.StopEffect();
m_sFlash.StopTweening();
m_sFlash.Sleep(GAMESTATE->m_fCurBPS /16);
m_sFlash.SetDiffuseAlpha(1);
m_sFlash.BeginTweening(1/GAMESTATE->m_fCurBPS * 0.5f);
m_sFlash.SetDiffuseAlpha(0);
m_sFlash.Sleep( GAMESTATE->m_fCurBPS/16 );
m_sFlash.SetDiffuseAlpha( 1 );
m_sFlash.BeginTweening( 1/GAMESTATE->m_fCurBPS * 0.5f );
m_sFlash.SetDiffuseAlpha( 0 );
}
void BeginnerHelper::Update( float fDeltaTime )
{
if(!m_bInitialized)
if( !m_bInitialized )
return;
// the row we want to check on this update
int iCurRow = BeatToNoteRowNotRounded(GAMESTATE->m_fSongBeat + 0.4f);
int iCurRow = BeatToNoteRowNotRounded( GAMESTATE->m_fSongBeat + 0.4f );
FOREACH_EnabledPlayer( pn )
{
for(int iRow=m_iLastRowChecked; iRow<iCurRow; iRow++)
for( int iRow=m_iLastRowChecked; iRow<iCurRow; iRow++ )
{
// Check if there are any notes at all on this row.. If not, save scanning.
if(!m_NoteData[pn].IsThereATapAtRow(iRow))
if( !m_NoteData[pn].IsThereATapAtRow(iRow) )
continue;
// Find all steps on this row, in order to show the correct animations
@@ -344,7 +346,7 @@ void BeginnerHelper::Update( float fDeltaTime )
iStep |= 1 << t;
// Assign new data
this->Step(pn, iStep);
this->Step( pn, iStep );
}
}
@@ -352,19 +354,19 @@ void BeginnerHelper::Update( float fDeltaTime )
m_iLastRowChecked = iCurRow;
// Update animations
ActorFrame::Update(fDeltaTime);
m_pDancePad->Update(fDeltaTime);
m_sFlash.Update(fDeltaTime);
ActorFrame::Update( fDeltaTime );
m_pDancePad->Update( fDeltaTime );
m_sFlash.Update( fDeltaTime );
float beat = (fDeltaTime*GAMESTATE->m_fCurBPS);
float beat = fDeltaTime*GAMESTATE->m_fCurBPS;
// If this is not a human player, the dancer is not shown
FOREACH_HumanPlayer( pu )
{
// Update dancer's animation and StepCircles
m_pDancer[pu]->Update( beat );
for(int scu=0; scu<NUM_PLAYERS; scu++)
for(int scue=0; scue<4; scue++)
m_sStepCircle[scu][scue].Update(beat);
for( int scu=0; scu<NUM_PLAYERS; scu++ )
for( int scue=0; scue<4; scue++ )
m_sStepCircle[scu][scue].Update( beat );
}
}