#include "stdafx.h" /* ----------------------------------------------------------------------------- File: Player.cpp Desc: Object that accepts pad input, knocks down ColorArrows that were stepped on, and keeps score for the player. Copyright (c) 2001 Chris Danford. All rights reserved. ----------------------------------------------------------------------------- */ #include "ScreenDimensions.h" #include "Math.h" // for fabs() #include "Player.h" #include "RageUtil.h" #include "ThemeManager.h" const float LIFE_PERFECT = 0.010f; const float LIFE_GREAT = 0.005f; const float LIFE_GOOD = 0.000f; const float LIFE_BOO = -0.010f; const float LIFE_MISS = -0.020f; const int ARROW_SIZE = 64; const float ARROW_X_OFFSET[6] = { ARROW_SIZE*-2.5, ARROW_SIZE*-1.5, ARROW_SIZE*-0.5, ARROW_SIZE* 0.5, ARROW_SIZE* 1.5, ARROW_SIZE* 2.5 }; const float GRAY_ARROW_Y = ARROW_SIZE * 1.5; const float ARROW_GAP = 70; const int NUM_FRAMES_IN_COLOR_ARROW_SPRITE = 12; const float JUDGEMENT_DISPLAY_TIME = 0.6f; const float JUDGEMENT_Y_OFFSET = 20; const float HOLD_JUDGEMENT_Y = GRAY_ARROW_Y + 80; const float COMBO_TWEEN_TIME = 0.5f; const float COMBO_Y = (CENTER_Y+60); const int LIEFMETER_NUM_PILLS = 17; const float LIFEMETER_Y = 30; const float LIFEMETER_PILLS_Y = LIFEMETER_Y; const float PILL_OFFSET_Y[LIEFMETER_NUM_PILLS] = { 0.3f, 0.7f, 1.0f, 0.7f, 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f // kind of a sin wave }; const float SCORE_Y = SCREEN_HEIGHT - 40; Player::Player( PlayerOptions po, PlayerNumber pn ) { m_PlayerOptions = po; m_PlayerNumber = pn; m_iCurCombo = 0; m_iMaxCombo = 0; m_fLifePercentage = 0.50f; m_fScore = 0; // init step elements for( int i=0; i mapStepToRotation; // arrow facing left is rotation 0 mapStepToRotation[STEP_PAD1_LEFT] = 0; mapStepToRotation[STEP_PAD1_UPLEFT] = D3DX_PI/4.0f; mapStepToRotation[STEP_PAD1_DOWN] = -D3DX_PI/2.0f; mapStepToRotation[STEP_PAD1_UP] = D3DX_PI/2.0f; mapStepToRotation[STEP_PAD1_UPRIGHT]= D3DX_PI*3.0f/4.0f; mapStepToRotation[STEP_PAD1_RIGHT] = D3DX_PI; mapStepToRotation[STEP_PAD2_LEFT] = mapStepToRotation[STEP_PAD1_LEFT]; mapStepToRotation[STEP_PAD2_UPLEFT] = mapStepToRotation[STEP_PAD1_UPLEFT]; mapStepToRotation[STEP_PAD2_DOWN] = mapStepToRotation[STEP_PAD1_DOWN]; mapStepToRotation[STEP_PAD2_UP] = mapStepToRotation[STEP_PAD1_UP]; mapStepToRotation[STEP_PAD2_UPRIGHT]= mapStepToRotation[STEP_PAD1_UPRIGHT]; mapStepToRotation[STEP_PAD2_RIGHT] = mapStepToRotation[STEP_PAD1_RIGHT]; switch( GAMEINFO->m_GameMode ) { case MODE_SINGLE: case MODE_VERSUS: case MODE_COUPLE: m_iNumColumns = 4; // LEFT, DOWN, UP, RIGHT m_StepToColumnNumber[STEP_PAD1_LEFT] = 0; m_StepToColumnNumber[STEP_PAD1_DOWN] = 1; m_StepToColumnNumber[STEP_PAD1_UP] = 2; m_StepToColumnNumber[STEP_PAD1_RIGHT] = 3; m_ColumnNumberToStep[0] = STEP_PAD1_LEFT; m_ColumnNumberToStep[1] = STEP_PAD1_DOWN; m_ColumnNumberToStep[2] = STEP_PAD1_UP; m_ColumnNumberToStep[3] = STEP_PAD1_RIGHT; m_ColumnToRotation[0] = mapStepToRotation[STEP_PAD1_LEFT]; m_ColumnToRotation[1] = mapStepToRotation[STEP_PAD1_DOWN]; m_ColumnToRotation[2] = mapStepToRotation[STEP_PAD1_UP]; m_ColumnToRotation[3] = mapStepToRotation[STEP_PAD1_RIGHT]; break; case MODE_SOLO: m_iNumColumns = 6; // LEFT, UP+LEFT, DOWN, UP, UP+RIGHT, RIGHT m_StepToColumnNumber[STEP_PAD1_LEFT] = 0; m_StepToColumnNumber[STEP_PAD1_UPLEFT] = 1; m_StepToColumnNumber[STEP_PAD1_DOWN] = 2; m_StepToColumnNumber[STEP_PAD1_UP] = 3; m_StepToColumnNumber[STEP_PAD1_UPRIGHT] = 4; m_StepToColumnNumber[STEP_PAD1_RIGHT] = 5; m_ColumnNumberToStep[0] = STEP_PAD1_LEFT; m_ColumnNumberToStep[1] = STEP_PAD1_UPLEFT; m_ColumnNumberToStep[2] = STEP_PAD1_DOWN; m_ColumnNumberToStep[3] = STEP_PAD1_UP; m_ColumnNumberToStep[4] = STEP_PAD1_UPRIGHT; m_ColumnNumberToStep[5] = STEP_PAD1_RIGHT; m_ColumnToRotation[0] = mapStepToRotation[STEP_PAD1_LEFT]; m_ColumnToRotation[1] = mapStepToRotation[STEP_PAD1_UPLEFT]; m_ColumnToRotation[2] = mapStepToRotation[STEP_PAD1_DOWN]; m_ColumnToRotation[3] = mapStepToRotation[STEP_PAD1_UP]; m_ColumnToRotation[4] = mapStepToRotation[STEP_PAD1_UPRIGHT]; m_ColumnToRotation[5] = mapStepToRotation[STEP_PAD1_RIGHT]; break; case MODE_DOUBLE: m_iNumColumns = 8; // 1_LEFT, 1_DOWN, 1_UP, 1_RIGHT, 2_LEFT, 2_DOWN, 2_UP, 2_RIGHT m_StepToColumnNumber[STEP_PAD1_LEFT] = 0; m_StepToColumnNumber[STEP_PAD1_DOWN] = 1; m_StepToColumnNumber[STEP_PAD1_UP] = 2; m_StepToColumnNumber[STEP_PAD1_RIGHT] = 3; m_StepToColumnNumber[STEP_PAD2_LEFT] = 4; m_StepToColumnNumber[STEP_PAD2_DOWN] = 5; m_StepToColumnNumber[STEP_PAD2_UP] = 6; m_StepToColumnNumber[STEP_PAD2_RIGHT] = 7; m_ColumnNumberToStep[0] = STEP_PAD1_LEFT; m_ColumnNumberToStep[1] = STEP_PAD1_DOWN; m_ColumnNumberToStep[2] = STEP_PAD1_UP; m_ColumnNumberToStep[3] = STEP_PAD1_RIGHT; m_ColumnNumberToStep[4] = STEP_PAD2_LEFT; m_ColumnNumberToStep[5] = STEP_PAD2_DOWN; m_ColumnNumberToStep[6] = STEP_PAD2_UP; m_ColumnNumberToStep[7] = STEP_PAD2_RIGHT; m_ColumnToRotation[0] = mapStepToRotation[STEP_PAD1_LEFT]; m_ColumnToRotation[1] = mapStepToRotation[STEP_PAD1_DOWN]; m_ColumnToRotation[2] = mapStepToRotation[STEP_PAD1_UP]; m_ColumnToRotation[3] = mapStepToRotation[STEP_PAD1_RIGHT]; m_ColumnToRotation[4] = mapStepToRotation[STEP_PAD2_LEFT]; m_ColumnToRotation[5] = mapStepToRotation[STEP_PAD2_DOWN]; m_ColumnToRotation[6] = mapStepToRotation[STEP_PAD2_UP]; m_ColumnToRotation[7] = mapStepToRotation[STEP_PAD2_RIGHT]; break; default: ASSERT( true ); // invalid GameMode } // init arrow rotations for( int c=0; c < MAX_NUM_COLUMNS; c++ ) { m_GrayArrow[c].SetRotation( m_ColumnToRotation[c] ); m_GhostArrow[c].SetRotation( m_ColumnToRotation[c] ); m_GhostArrowBright[c].SetRotation( m_ColumnToRotation[c] ); m_HoldGhostArrow[c].SetRotation( m_ColumnToRotation[c] ); m_ColorArrow[c].SetRotation( m_ColumnToRotation[c] ); } // holder for judgement and combo displays m_frameJudgementAndCombo.AddActor( &m_sprJudgement ); m_frameJudgementAndCombo.AddActor( &m_sprCombo ); m_frameJudgementAndCombo.AddActor( &m_textComboNumber ); m_frameJudgementAndCombo.SetXY( CENTER_X, CENTER_Y ); // judgement m_fJudgementDisplayCountdown = 0; m_sprJudgement.Load( THEME->GetPathTo(GRAPHIC_JUDGEMENT) ); m_sprJudgement.StopAnimating(); m_sprJudgement.SetXY( 0, m_PlayerOptions.m_bReverseScroll ? JUDGEMENT_Y_OFFSET : -JUDGEMENT_Y_OFFSET ); // combo m_sprCombo.Load( THEME->GetPathTo(GRAPHIC_COMBO) ); m_sprCombo.StopAnimating(); m_sprCombo.SetXY( 40, m_PlayerOptions.m_bReverseScroll ? -JUDGEMENT_Y_OFFSET : JUDGEMENT_Y_OFFSET+2 ); m_sprCombo.SetZoom( 1.0f ); m_textComboNumber.Load( THEME->GetPathTo(FONT_COMBO_NUMBERS) ); m_textComboNumber.SetXY( -40, m_PlayerOptions.m_bReverseScroll ? -JUDGEMENT_Y_OFFSET : JUDGEMENT_Y_OFFSET ); m_textComboNumber.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible m_sprCombo.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible // hold judgement for( c=0; cGetPathTo(GRAPHIC_JUDGEMENT) ); m_sprHoldJudgement[c].StopAnimating(); } // life meter m_sprLifeMeterFrame.Load( THEME->GetPathTo(GRAPHIC_LIFEMETER_FRAME) ); m_sprLifeMeterFrame.StopAnimating(); m_sprLifeMeterPills.Load( THEME->GetPathTo(GRAPHIC_LIFEMETER_PILLS) ); m_sprLifeMeterPills.StopAnimating(); // score m_sprScoreFrame.Load( THEME->GetPathTo(GRAPHIC_SCORE_FRAME) ); m_ScoreDisplay.SetScore( 0 ); SetX( CENTER_X ); // assist m_soundAssistTick.Load( THEME->GetPathTo(SOUND_ASSIST) ); } void Player::SetX( float fX ) { m_fArrowsCenterX = fX; int fXInt = (int)m_fArrowsCenterX; SetGrayArrowsX(fXInt); SetGhostArrowsX(fXInt); SetColorArrowsX(fXInt); SetJudgementX(fXInt); SetComboX(fXInt); SetScoreX(fXInt); SetLifeMeterX(fXInt); m_frameJudgementAndCombo.SetX(fX); } void Player::SetSteps( const Steps& newSteps, bool bLoadOnlyLeftSide, bool bLoadOnlyRightSide ) { Step tempSteps[MAX_STEP_ELEMENTS]; CArray tempHoldSteps; // copy the steps into our tempSteps where we will transform them for( int i=0; i 0 ) { SetJudgement( miss ); EndCombo(); for( int i=0; iIsButtonDown( PlayerI ) ) // they're holding the button down { int iCol = m_StepToColumnNumber[ hs.m_Step ]; m_HoldGhostArrow[iCol].Step(); } } // update the logic if( (m_HoldStepScores[i].m_HoldScore == HoldStepScore::HOLD_SCORE_NONE || m_HoldStepScores[i].m_HoldScore == HoldStepScore::HOLD_STEPPED_ON) && // this hold doesn't already have a score fStartBeat+fMaxBeatDifference/2 < m_fSongBeat && m_fSongBeat < fEndBeat-fMaxBeatDifference/2 ) // if the song beat is in the range of this hold { PlayerInput PlayerI = { m_PlayerNumber, hs.m_Step }; if( !GAMEINFO->IsButtonDown( PlayerI ) ) // they're not holding the button down { m_HoldStepScores[i].m_HoldScore = HoldStepScore::HOLD_SCORE_NG; int iCol = m_StepToColumnNumber[ hs.m_Step ]; SetHoldJudgement( iCol, HoldStepScore::HOLD_SCORE_NG ); } } } // check for HoldStep completes for( i=0; i fEndBeat && // if this hold step is in the past m_HoldStepScores[i].m_HoldScore == HoldStepScore::HOLD_STEPPED_ON ) // and it doesn't yet have a score { m_HoldStepScores[i].m_HoldScore = HoldStepScore::HOLD_SCORE_OK; int iCol = m_StepToColumnNumber[ hs.m_Step ]; SetHoldJudgement( iCol, HoldStepScore::HOLD_SCORE_OK ); } } UpdateGrayArrows( fDeltaTime ); UpdateColorArrows( fDeltaTime ); UpdateGhostArrows( fDeltaTime ); UpdateJudgement( fDeltaTime ); UpdateCombo( fDeltaTime ); UpdateScore( fDeltaTime ); UpdateLifeMeter( fDeltaTime ); m_frameJudgementAndCombo.Update( fDeltaTime ); } void Player::CrossedIndex( int iIndex ) { if( GAMEINFO->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK ) { bool bThereIsANoteThisIndex = false; bThereIsANoteThisIndex |= (m_OriginalStep[iIndex] != STEP_NONE); for( int i=0; i= 100 ) m_GhostArrowBright[index].Step( score ); else m_GhostArrow[index].Step( score ); } void Player::UpdateColorArrows( float fDeltaTime ) { int iIndexFirstArrowToDraw = BeatToStepIndex( m_fSongBeat - 2.0f ); // 2 beats earlier if( iIndexFirstArrowToDraw < 0 ) iIndexFirstArrowToDraw = 0; int iIndexLastArrowToDraw = BeatToStepIndex( m_fSongBeat + 7.0f ); // 7 beats later for( int c=0; c < m_iNumColumns; c++ ) m_ColorArrow[c].Update( fDeltaTime ); } // // modified to add color shifting to the arrow texture // void Player::DrawColorArrows() { //RageLog( "ColorArrows::Draw(%f)", fSongBeat ); int iBaseFrameNo = (int)(m_fSongBeat*2.5) % 12; // 2.5 is a "fudge number" :-) This should be based on BPM if( iBaseFrameNo < 0 ) iBaseFrameNo = 0; if( m_fSongBeat < 0 ) m_fSongBeat = 0; int iIndexFirstArrowToDraw = BeatToStepIndex( m_fSongBeat - 2.0f ); // 2 beats earlier if( iIndexFirstArrowToDraw < 0 ) iIndexFirstArrowToDraw = 0; int iIndexLastArrowToDraw = BeatToStepIndex( m_fSongBeat + 7.0f ); // 7 beats later //RageLog( "Drawing elements %d through %d", iIndexFirstArrowToDraw, iIndexLastArrowToDraw ); for( int i=iIndexFirstArrowToDraw; i<=iIndexLastArrowToDraw; i++ ) // for each row { if( m_LeftToStepOn[i] != 0 || // this step is not yet complete m_StepScore[i] == good || m_StepScore[i] == boo || m_StepScore[i] == miss ) { float fYOffset = GetColorArrowYOffset( i, m_fSongBeat ); float fYPos = GetColorArrowYPos( i, m_fSongBeat ); if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; float fAlpha = GetColorArrowAlphaFromYOffset( fYOffset ); // beats until the note is stepped on. float fBeatsTilStep = StepIndexToBeat( i ) - m_fSongBeat; //RageLog( "iYPos: %d, iFrameNo: %d, m_OriginalStep[i]: %d", iYPos, iFrameNo, m_OriginalStep[i] ); for( int c=0; c < m_iNumColumns; c++ ) { // for each arrow column if( m_OriginalStep[i] & m_ColumnNumberToStep[c] ) { // this column is still unstepped on? m_ColorArrow[c].SetY( fYPos ); m_ColorArrow[c].SetIndexAndBeat( i, m_fSongBeat ); m_ColorArrow[c].SetAlpha( fAlpha ); m_ColorArrow[c].Draw(); } } } // end if there is a step } // end foreach arrow to draw // draw all freeze arrows for( i=0; i iIndexLastArrowToDraw ) ) { continue; } HoldStepScore::HoldScore &score = m_HoldStepScores[i].m_HoldScore; int iColNum = m_StepToColumnNumber[ hs.m_Step ]; switch( score ) { case HoldStepScore::HOLD_SCORE_OK: continue; // don't draw case HoldStepScore::HOLD_SCORE_NONE: case HoldStepScore::HOLD_SCORE_NG: m_ColorArrow[iColNum].SetGrayPartClear(); break; case HoldStepScore::HOLD_STEPPED_ON: m_ColorArrow[iColNum].SetGrayPartFull(); break; } // draw the gray parts for( int j=hs.m_iEndIndex; j>=hs.m_iStartIndex; j-- ) // for each arrow in this freeze { // check if this hold step is off the the screen if( j < iIndexFirstArrowToDraw || iIndexLastArrowToDraw < j) continue; // skip this arrow float fYOffset = GetColorArrowYOffset( j, m_fSongBeat ); float fYPos = GetColorArrowYPos( j, m_fSongBeat ); if( score == HoldStepScore::HOLD_STEPPED_ON || score == HoldStepScore::HOLD_SCORE_OK ) { if( fYPos < GetGrayArrowYPos() ) continue; // don't draw } if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; m_ColorArrow[iColNum].SetY( fYPos ); float fAlpha = GetColorArrowAlphaFromYOffset( fYOffset ); m_ColorArrow[iColNum].SetAlpha( fAlpha ); m_ColorArrow[iColNum].DrawGrayPart(); } // draw the color parts for( j=hs.m_iEndIndex; j>=hs.m_iStartIndex; j-- ) // for each arrow in this freeze { // check if this hold step is off the the screen if( j < iIndexFirstArrowToDraw || iIndexLastArrowToDraw < j) continue; // skip this arrow float fYOffset = GetColorArrowYOffset( j, m_fSongBeat ); float fYPos = GetColorArrowYPos( j, m_fSongBeat ); m_ColorArrow[iColNum].SetY( fYPos ); if( score == HoldStepScore::HOLD_STEPPED_ON || score == HoldStepScore::HOLD_SCORE_OK ) { if( fYPos < GetGrayArrowYPos() ) continue; // don't draw } if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; m_ColorArrow[iColNum].SetY( fYPos ); D3DXCOLOR color( (float)(j-hs.m_iStartIndex)/(float)(hs.m_iEndIndex-hs.m_iStartIndex), 1, 0, 1 ); // color shifts from green to yellow m_ColorArrow[iColNum].SetDiffuseColor( color ); float fAlpha = GetColorArrowAlphaFromYOffset( fYOffset ); m_ColorArrow[iColNum].SetAlpha( fAlpha ); m_ColorArrow[iColNum].DrawColorPart(); } // draw the first arrow on top of the others j = hs.m_iStartIndex; float fYOffset = GetColorArrowYOffset( j, m_fSongBeat ); float fYPos = GetColorArrowYPos( j, m_fSongBeat ); if( score == HoldStepScore::HOLD_STEPPED_ON || score == HoldStepScore::HOLD_SCORE_OK ) fYPos = max( fYPos, GetGrayArrowYPos() ); if( m_PlayerOptions.m_bReverseScroll ) fYPos = SCREEN_HEIGHT - fYPos; m_ColorArrow[iColNum].SetY( fYPos ); m_ColorArrow[iColNum].SetIndexAndBeat( i, m_fSongBeat ); D3DXCOLOR color( 0, 1, 0, 1 ); // color shifts from green to yellow m_ColorArrow[iColNum].SetDiffuseColor( color ); float fAlpha = GetColorArrowAlphaFromYOffset( fYOffset ); m_ColorArrow[iColNum].SetAlpha( fAlpha ); m_ColorArrow[iColNum].Draw(); } } float Player::GetColorArrowYPos( int iStepIndex, float fSongBeat ) { float fBeatsUntilStep = StepIndexToBeat( iStepIndex ) - fSongBeat; float fYOffset = fBeatsUntilStep * ARROW_GAP * m_PlayerOptions.m_fArrowScrollSpeed; switch( m_PlayerOptions.m_EffectType ) { case PlayerOptions::EFFECT_BOOST: fYOffset *= 1.4f / ((fYOffset+SCREEN_HEIGHT/1.6f)/SCREEN_HEIGHT); break; case PlayerOptions::EFFECT_WAVE: fYOffset += 15.0f*(float)sin( fYOffset/38.0f ); break; } float fYPos = fYOffset + GRAY_ARROW_Y; return fYPos; } float Player::GetColorArrowYOffset( int iStepIndex, float fSongBeat ) { float fBeatsUntilStep = StepIndexToBeat( iStepIndex ) - fSongBeat; float fYOffset = fBeatsUntilStep * ARROW_GAP * m_PlayerOptions.m_fArrowScrollSpeed; switch( m_PlayerOptions.m_EffectType ) { case PlayerOptions::EFFECT_BOOST: fYOffset *= 1.4f / ((fYOffset+SCREEN_HEIGHT/1.6f)/SCREEN_HEIGHT); break; case PlayerOptions::EFFECT_WAVE: fYOffset += 15.0f*(float)sin( fYOffset/38.0f ); break; } return fYOffset; } float Player::GetColorArrowAlphaFromYOffset( float fYOffset ) { float fAlpha; switch( m_PlayerOptions.m_AppearanceType ) { case PlayerOptions::APPEARANCE_VISIBLE: fAlpha = 1; break; case PlayerOptions::APPEARANCE_HIDDEN: // fAlpha = m_PlayerOptions.m_bReverseScroll ? ((SCREEN_HEIGHT-(fYPos-200))/200) : ((fYPos-200)/200); fAlpha = (fYOffset-100)/200; break; case PlayerOptions::APPEARANCE_SUDDEN: // fAlpha = m_PlayerOptions.m_bReverseScroll ? ((SCREEN_HEIGHT-(fYPos+200))/200) : ((fYPos+200)/200); fAlpha = ((SCREEN_HEIGHT-fYOffset)-280)/200; break; case PlayerOptions::APPEARANCE_STEALTH: fAlpha = 0; break; }; if( fYOffset < 0 ) fAlpha = 1; return fAlpha; }; float Player::GetGrayArrowYPos() { return GRAY_ARROW_Y; } void Player::SetJudgementX( int iNewX ) { // the frame will do this for us //float fY = JUDGEMENT_Y; //if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; //m_sprJudgement.SetXY( iNewX, fY ); float fY = HOLD_JUDGEMENT_Y; if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; for( int c=0; c 0 ) m_fHoldJudgementDisplayCountdown[c] -= fDeltaTime; m_sprHoldJudgement[c].Update( fDeltaTime ); } } void Player::DrawJudgement() { //if( m_fJudgementDisplayCountdown > 0.0 ) // m_sprJudgement.Draw(); // the frame will take care of this for us for( int c=0; c 0.0 ) m_sprHoldJudgement[c].Draw(); } } void Player::SetJudgement( StepScore score ) { //RageLog( "Judgement::SetJudgement()" ); switch( score ) { case perfect: m_sprJudgement.SetState( 0 ); break; case great: m_sprJudgement.SetState( 1 ); break; case good: m_sprJudgement.SetState( 2 ); break; case boo: m_sprJudgement.SetState( 3 ); break; case miss: m_sprJudgement.SetState( 4 ); break; } m_fJudgementDisplayCountdown = JUDGEMENT_DISPLAY_TIME; if( score == miss ) { // falling down m_sprJudgement.SetY( (m_PlayerOptions.m_bReverseScroll ? JUDGEMENT_Y_OFFSET : -JUDGEMENT_Y_OFFSET) - 30 ); m_sprJudgement.SetZoom( 1.0f ); m_sprJudgement.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // visible m_sprJudgement.BeginTweening( JUDGEMENT_DISPLAY_TIME ); m_sprJudgement.SetTweenY( (m_PlayerOptions.m_bReverseScroll ? JUDGEMENT_Y_OFFSET : -JUDGEMENT_Y_OFFSET) + 30 ); } else { // zooming out m_sprJudgement.StopTweening(); m_sprJudgement.SetY( (m_PlayerOptions.m_bReverseScroll ? JUDGEMENT_Y_OFFSET : -JUDGEMENT_Y_OFFSET) ); m_sprJudgement.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // visible m_frameJudgementAndCombo.SetZoom( 1.35f ); m_frameJudgementAndCombo.BeginTweening( JUDGEMENT_DISPLAY_TIME/5.0f ); m_frameJudgementAndCombo.SetTweenZoom( 1.0f ); /* m_sprJudgement.SetZoom( 1.5f ); m_sprJudgement.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // visible m_sprJudgement.BeginTweening( JUDGEMENT_DISPLAY_TIME/3.0 ); m_sprJudgement.SetTweenZoom( 1.0f ); */ } } void Player::SetHoldJudgement( int iCol, HoldStepScore::HoldScore score ) { //RageLog( "Judgement::SetJudgement()" ); switch( score ) { case HoldStepScore::HOLD_SCORE_NONE: m_sprHoldJudgement[iCol].SetState( 0 ); break; // freeze! case HoldStepScore::HOLD_SCORE_OK: m_sprHoldJudgement[iCol].SetState( 7 ); break; case HoldStepScore::HOLD_SCORE_NG: m_sprHoldJudgement[iCol].SetState( 8 ); break; } m_fHoldJudgementDisplayCountdown[iCol] = JUDGEMENT_DISPLAY_TIME; if( score == HoldStepScore::HOLD_SCORE_NG ) { // falling down float fY = HOLD_JUDGEMENT_Y; if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; m_sprHoldJudgement[iCol].SetY( fY - 10 ); m_sprHoldJudgement[iCol].SetZoom( 1.0f ); m_sprHoldJudgement[iCol].BeginTweening( JUDGEMENT_DISPLAY_TIME ); m_sprHoldJudgement[iCol].SetTweenY( fY + 10 ); } else { // zooming out float fY = HOLD_JUDGEMENT_Y; if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; m_sprHoldJudgement[iCol].SetY( fY ); m_sprHoldJudgement[iCol].SetZoom( 1.5f ); m_sprHoldJudgement[iCol].BeginTweening( JUDGEMENT_DISPLAY_TIME/3.0f ); m_sprHoldJudgement[iCol].SetTweenZoom( 1.0f ); } } void Player::SetComboX( int iNewX ) { float fY; fY = COMBO_Y; if( m_PlayerOptions.m_bReverseScroll ) fY = SCREEN_HEIGHT - fY; //m_sprCombo.SetXY( iNewX+40, fY ); // the frame will do this for us //m_textComboNumber.SetXY( iNewX-50, fY ); } void Player::UpdateCombo( float fDeltaTime ) { //m_sprCombo.Update( fDeltaTime ); // the frame will do this for us //m_textComboNumber.Update( fDeltaTime ); // the frame will do this for us } void Player::DrawCombo() { // the frame will do this for us // if( m_bComboVisible ) // { // m_textComboNumber.Draw(); // m_sprCombo.Draw(); // } } void Player::ContinueCombo() { m_iCurCombo++; // new max combo if( m_iCurCombo > m_iMaxCombo ) m_iMaxCombo = m_iCurCombo; if( m_iCurCombo <= 4 ) { m_textComboNumber.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible m_sprCombo.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible } else { m_textComboNumber.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // visible m_sprCombo.SetDiffuseColor( D3DXCOLOR(1,1,1,1) ); // visible m_textComboNumber.SetText( ssprintf("%d", m_iCurCombo) ); float fNewZoom = 0.5f + m_iCurCombo/800.0f; m_textComboNumber.SetZoom( fNewZoom ); m_textComboNumber.SetX( -40 - (fNewZoom-1)*30 ); m_textComboNumber.SetY( m_PlayerOptions.m_bReverseScroll ? -JUDGEMENT_Y_OFFSET : JUDGEMENT_Y_OFFSET ); //m_textComboNumber.BeginTweening( COMBO_TWEEN_TIME ); //m_textComboNumber.SetTweenZoom( 1 ); } } void Player::EndCombo() { m_iCurCombo = 0; m_textComboNumber.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible m_sprCombo.SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // invisible } void Player::SetLifeMeterX( int iNewX ) { m_sprLifeMeterFrame.SetXY( (float)iNewX, LIFEMETER_Y ); m_sprLifeMeterPills.SetXY( (float)iNewX, LIFEMETER_PILLS_Y ); } void Player::UpdateLifeMeter( float fDeltaTime ) { m_sprLifeMeterFrame.Update( fDeltaTime ); m_sprLifeMeterPills.Update( fDeltaTime ); } void Player::DrawLifeMeter() { float fBeatPercentage = m_fSongBeat - (int)m_fSongBeat; int iOffsetStart = roundf( LIEFMETER_NUM_PILLS*fBeatPercentage ); m_sprLifeMeterFrame.Draw(); float iX = m_sprLifeMeterFrame.GetX() - m_sprLifeMeterFrame.GetZoomedWidth()/2 + 27; int iNumPills = (int)(m_sprLifeMeterPills.GetNumStates() * m_fLifePercentage); int iPillWidth = (int)m_sprLifeMeterPills.GetZoomedWidth(); for( int i=0; i= 0 ); m_ScoreDisplay.SetScore( m_fScore ); }