diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 54fcd5323c..f582db33bc 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -11,6 +11,7 @@ #include "Actor.h" #include +#include "RageScreen.h" Actor::Actor() @@ -20,16 +21,12 @@ Actor::Actor() void Actor::Init() { - m_size = D3DXVECTOR2( 0, 0 ); - m_pos = D3DXVECTOR2( 0, 0 ); - m_rotation = D3DXVECTOR3( 0, 0, 0 ); - m_scale = D3DXVECTOR2( 1, 1 ); - m_color = D3DXCOLOR( 1, 1, 1, 1 ); - - m_start_pos = m_end_pos = D3DXVECTOR2( 0.0f, 0.0f ); - m_start_rotation= m_end_rotation = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); - m_start_scale = m_end_scale = D3DXVECTOR2( 1.0f, 1.0f ); - m_start_color = m_end_color = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ); + m_size = m_start_pos = m_end_pos = D3DXVECTOR2( 0, 0 ); + m_pos = m_start_pos = m_end_pos = D3DXVECTOR2( 0, 0 ); + m_rotation = m_start_rotation = m_end_rotation = D3DXVECTOR3( 0, 0, 0 ); + m_scale = m_start_scale = m_end_scale = D3DXVECTOR2( 1, 1 ); + m_colorDiffuse = m_start_colorDiffuse = m_end_colorDiffuse= D3DXCOLOR( 1, 1, 1, 1 ); + m_colorAdd = m_start_colorAdd = m_end_colorAdd = D3DXCOLOR( 0, 0, 0, 0 ); m_TweenType = no_tween; m_fTweenTime = 0.0f; @@ -37,10 +34,108 @@ void Actor::Init() } +void Actor::Draw() +{ + D3DXVECTOR2 pos = m_pos; + D3DXVECTOR3 rotation = m_rotation; + D3DXVECTOR2 scale = m_scale; + + // update properties based on SpriteEffects + switch( m_Effect ) + { + case no_effect: + break; + case blinking: + break; + case camelion: + break; + case glowing: + break; + case wagging: + rotation.z = m_fWagRadians * (float)sin( + (m_fWagTimer / m_fWagPeriod) // percent through wag + * 2.0 * D3DX_PI ); + break; + case spinning: + // nothing special needed + break; + case vibrating: + pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); + pos.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); + break; + case flickering: + break; + } + + + LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice(); + + // calculate and apply world transform + D3DXMATRIX matWorld, matTemp; + D3DXMatrixIdentity( &matWorld ); // pass this along to each thing we draw and let it set it's own world matrix + D3DXMatrixScaling( &matTemp, scale.x, scale.y, 1 ); // add in the zoom + matWorld *= matTemp; + D3DXMatrixRotationYawPitchRoll( &matTemp, rotation.y, rotation.x, rotation.z ); // add in the rotation + matWorld *= matTemp; + D3DXMatrixTranslation( &matTemp, pos.x, pos.y, 0 ); // add in the translation + matWorld *= matTemp; + D3DXMatrixTranslation( &matTemp, -0.5f, -0.5f, 0 ); // shift to align texels with pixels + matWorld *= matTemp; + pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); + +} + + void Actor::Update( const float &fDeltaTime ) { // RageLog( "Actor::Update( %f )", fDeltaTime ); + // update effect + switch( m_Effect ) + { + case no_effect: + break; + case blinking: + case camelion: + case glowing: + if( m_bTweeningTowardEndColor ) { + m_fPercentBetweenColors += m_fDeltaPercentPerSecond * fDeltaTime; + if( m_fPercentBetweenColors > 1.0f ) { + m_fPercentBetweenColors = 1.0f; + m_bTweeningTowardEndColor = FALSE; + } + } + else { // !m_bTweeningTowardEndColor + m_fPercentBetweenColors -= m_fDeltaPercentPerSecond * fDeltaTime; + if( m_fPercentBetweenColors < 0.0f ) { + m_fPercentBetweenColors = 0.0f; + m_bTweeningTowardEndColor = TRUE; + } + } + RageLog( "Actor::m_fPercentBetweenColors %f", m_fPercentBetweenColors ); + break; + case wagging: + m_fWagTimer += fDeltaTime; + if( m_fWagTimer > m_fWagPeriod ) + m_fWagTimer -= m_fWagPeriod; + break; + case spinning: + float rotation; + rotation = GetRotation(); + rotation += m_fSpinSpeed * fDeltaTime; + if( rotation > 2.0f * D3DX_PI ) + rotation -= 2.0f * D3DX_PI; + else if( rotation < 0.0f ) + rotation += 2.0f * D3DX_PI; + SetRotation( rotation ); + break; + case vibrating: + break; + case flickering: + break; + } + + // update tweening if( m_TweenType != no_tween ) // we are performing some type of tweening { @@ -51,47 +146,48 @@ void Actor::Update( const float &fDeltaTime ) m_pos = m_end_pos; m_scale = m_end_scale; m_rotation = m_end_rotation; - m_color = m_end_color; + m_colorDiffuse = m_end_colorDiffuse; + m_colorAdd = m_end_colorAdd; m_TweenType = no_tween; } else // Tweening. Recalcute the curent position. { - FLOAT fPercentThroughTween = m_fTimeIntoTween / m_fTweenTime; + float fPercentThroughTween = m_fTimeIntoTween / m_fTweenTime; // distort the percentage if appropriate if( m_TweenType == tween_bias_begin ) - fPercentThroughTween = (FLOAT) sqrt( fPercentThroughTween ); + fPercentThroughTween = (float) sqrt( fPercentThroughTween ); else if( m_TweenType == tweening_bias_end ) fPercentThroughTween = fPercentThroughTween * fPercentThroughTween; - m_pos = m_start_pos + (m_end_pos - m_start_pos )*fPercentThroughTween; - m_scale = m_start_scale + (m_end_scale - m_start_scale )*fPercentThroughTween; - m_rotation = m_start_rotation+ (m_end_rotation - m_start_rotation)*fPercentThroughTween; - m_color = m_start_color*(1.0f-fPercentThroughTween) + m_end_color*(fPercentThroughTween); + m_pos = m_start_pos + (m_end_pos - m_start_pos )*fPercentThroughTween; + m_scale = m_start_scale + (m_end_scale - m_start_scale )*fPercentThroughTween; + m_rotation = m_start_rotation+ (m_end_rotation - m_start_rotation)*fPercentThroughTween; + m_colorDiffuse = m_start_colorDiffuse*(1.0f-fPercentThroughTween) + m_end_colorDiffuse*(fPercentThroughTween); + m_colorAdd = m_start_colorAdd *(1.0f-fPercentThroughTween) + m_end_colorAdd *(fPercentThroughTween); } } // end if m_TweenType != no_tween - } -void Actor::TweenTo( FLOAT time, FLOAT x, FLOAT y, FLOAT zoom, FLOAT rot, D3DXCOLOR col, TweenType tt ) +void Actor::TweenTo( float time, float x, float y, float zoom, float rot, D3DXCOLOR col, TweenType tt ) { // set our tweeen starting values to the current position m_start_pos = m_pos; m_start_scale = m_scale; m_start_rotation = m_rotation; - m_start_color = m_color; + m_start_colorDiffuse = m_colorDiffuse; // set the ending tweening position to what the user asked for - m_end_pos.x = (FLOAT)x; - m_end_pos.y = (FLOAT)y; + m_end_pos.x = (float)x; + m_end_pos.y = (float)y; m_end_scale.x = zoom; m_end_scale.y = zoom; m_end_rotation.z = rot; - m_end_color = col; + m_end_colorDiffuse = col; m_TweenType = tt; m_fTweenTime = time; m_fTimeIntoTween = 0; @@ -99,27 +195,29 @@ void Actor::TweenTo( FLOAT time, FLOAT x, FLOAT y, FLOAT zoom, FLOAT rot, D3DXCO } -void Actor::BeginTweening( FLOAT time, TweenType tt ) +void Actor::BeginTweening( float time, TweenType tt ) { // set our tweeen starting and ending values to the current position - m_start_pos = m_end_pos = m_pos; - m_start_scale = m_end_scale = m_scale; - m_start_rotation = m_end_rotation = m_rotation; - m_start_color = m_end_color = m_color; + m_start_pos = m_end_pos = m_pos; + m_start_scale = m_end_scale = m_scale; + m_start_rotation = m_end_rotation = m_rotation; + m_start_colorDiffuse = m_end_colorDiffuse = m_colorDiffuse; + m_start_colorAdd = m_end_colorAdd = m_colorAdd; m_TweenType = tt; m_fTweenTime = time; m_fTimeIntoTween = 0; } -void Actor::SetTweenX( FLOAT x ) { m_end_pos.x = x; } -void Actor::SetTweenY( FLOAT y ) { m_end_pos.y = y; } -void Actor::SetTweenXY( FLOAT x, FLOAT y ) { SetTweenX(x); SetTweenY(y); } -void Actor::SetTweenZoom( FLOAT zoom ) { m_end_scale.x = zoom; m_end_scale.y = zoom; } -void Actor::SetTweenRotationX( FLOAT r ) { m_end_rotation.x = r; } -void Actor::SetTweenRotationY( FLOAT r ) { m_end_rotation.y = r; } -void Actor::SetTweenRotationZ( FLOAT r ) { m_end_rotation.z = r; } -void Actor::SetTweenColor( D3DXCOLOR c ) { m_end_color = c; } +void Actor::SetTweenX( float x ) { m_end_pos.x = x; } +void Actor::SetTweenY( float y ) { m_end_pos.y = y; } +void Actor::SetTweenXY( float x, float y ) { SetTweenX(x); SetTweenY(y); } +void Actor::SetTweenZoom( float zoom ) { m_end_scale.x = zoom; m_end_scale.y = zoom; } +void Actor::SetTweenRotationX( float r ) { m_end_rotation.x = r; } +void Actor::SetTweenRotationY( float r ) { m_end_rotation.y = r; } +void Actor::SetTweenRotationZ( float r ) { m_end_rotation.z = r; } +void Actor::SetTweenDiffuseColor( D3DXCOLOR c ) { m_end_colorDiffuse = c; } +void Actor::SetTweenAddColor( D3DXCOLOR c ) { m_end_colorAdd = c; } void Actor::ScaleTo( LPRECT pRect, StretchType st ) @@ -169,10 +267,75 @@ void Actor::StretchTo( LPRECT pRect ) int rect_cy = pRect->top + rect_height/2; // zoom factor needed to scale the Actor to fill the rectangle - FLOAT fNewZoomX = (FLOAT)fabs(rect_width / m_size.x); - FLOAT fNewZoomY = (FLOAT)fabs(rect_height / m_size.y); + float fNewZoomX = (float)fabs(rect_width / m_size.x); + float fNewZoomY = (float)fabs(rect_height / m_size.y); - SetXY( (FLOAT)rect_cx, (FLOAT)rect_cy ); + SetXY( (float)rect_cx, (float)rect_cy ); m_scale.x = fNewZoomX; m_scale.y = fNewZoomY; } + + + + +// effects + +void Actor::SetEffectNone() +{ + m_Effect = no_effect; + //m_color = D3DXCOLOR( 1.0,1.0,1.0,1.0 ); +} + +void Actor::SetEffectBlinking( float fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) +{ + m_Effect = blinking; + m_start_colorDiffuse = Color; + m_end_colorDiffuse = Color2; + //m_fPercentBetweenColors = 0.0; + //m_bTweeningTowardEndColor = TRUE; + m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; +} + +void Actor::SetEffectCamelion( float fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) +{ + m_Effect = camelion; + m_start_colorDiffuse = Color; + m_end_colorDiffuse = Color2; + //m_fPercentBetweenColors = 0.0; + //m_bTweeningTowardEndColor = TRUE; + m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; +} + +void Actor::SetEffectGlowing( float fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) +{ + m_Effect = glowing; + m_start_colorAdd = Color; + m_end_colorAdd = Color2; + //m_fPercentBetweenColors = 0.0; + //m_bTweeningTowardEndColor = TRUE; + m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; +} + +void Actor::SetEffectWagging( float fWagRadians, float fWagPeriod ) +{ + m_Effect = wagging; + m_fWagRadians = fWagRadians; + m_fWagPeriod = fWagPeriod; +} + +void Actor::SetEffectSpinning( float fSpinSpeed /*radians per second*/ ) +{ + m_Effect = spinning; + m_fSpinSpeed = fSpinSpeed; +} + +void Actor::SetEffectVibrating( float fVibrationDistance ) +{ + m_Effect = vibrating; + m_fVibrationDistance = fVibrationDistance; +} + +void Actor::SetEffectFlickering() +{ + m_Effect = flickering; +} \ No newline at end of file diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index cc8b40e25a..e75ca0f379 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -25,12 +25,17 @@ public: Actor(); enum TweenType { no_tween, tween_linear, tween_bias_begin, tweening_bias_end }; + enum Effect { no_effect, + blinking, camelion, glowing, + wagging, spinning, + vibrating, flickering + }; // let subclasses override virtual void Restore() {}; virtual void Invalidate() {}; - virtual void Draw() PURE; + virtual void Draw(); virtual void Update( const float &fDeltaTime ); virtual float GetX() { return m_pos.x; }; @@ -40,13 +45,13 @@ public: virtual void SetXY( float x, float y ) { m_pos.x = x; m_pos.y = y; m_TweenType = no_tween; }; // height and width vary depending on zoom - virtual float GetZoomedWidth() { return m_size.x * m_scale.x; } - virtual float GetZoomedHeight() { return m_size.y * m_scale.y; } - virtual void SetWidth( float width ){ m_size.x = width; } - virtual void SetHeight( float height ){ m_size.y = height; } + virtual float GetZoomedWidth() { return m_size.x * m_scale.x; } + virtual float GetZoomedHeight() { return m_size.y * m_scale.y; } + virtual void SetWidth( float width ){ m_size.x = width; } + virtual void SetHeight( float height ){ m_size.y = height; } virtual float GetZoom() { return m_scale.x; } - virtual void SetZoom( float zoom ) { m_scale.x = zoom; m_scale.y = zoom; } + virtual void SetZoom( float zoom ) { m_scale.x = zoom; m_scale.y = zoom; } virtual float GetRotation() { return m_rotation.z; } virtual void SetRotation( float rot ) { m_rotation.z = rot; } @@ -55,14 +60,16 @@ public: virtual float GetRotationY() { return m_rotation.y; } virtual void SetRotationY( float rot ) { m_rotation.y = rot; } - virtual void SetColor( D3DXCOLOR newColor ) { m_color = newColor; }; - virtual D3DXCOLOR GetColor() { return m_color; }; + virtual void SetDiffuseColor( D3DXCOLOR colorDiffuse ) { m_colorDiffuse = colorDiffuse; }; + virtual D3DXCOLOR GetDiffuseColor() { return m_colorDiffuse; }; + virtual void SetAddColor( D3DXCOLOR colorAdd ) { m_colorAdd = colorAdd; }; + virtual D3DXCOLOR GetAddColor() { return m_colorAdd; }; virtual void TweenTo( float time, float x, float y, float zoom = 1.0, float rot = 0.0, - D3DXCOLOR col = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ), + D3DXCOLOR colDiffuse = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ), TweenType tt = tween_linear ); virtual void BeginTweening( float time, TweenType tt = tween_linear ); @@ -73,14 +80,15 @@ public: virtual void SetTweenRotationX( float r ); virtual void SetTweenRotationY( float r ); virtual void SetTweenRotationZ( float r ); - virtual void SetTweenColor( D3DXCOLOR c ); + virtual void SetTweenDiffuseColor( D3DXCOLOR c ); + virtual void SetTweenAddColor( D3DXCOLOR c ); // NOTE: GetEdge functions don't consider rotation - virtual float GetLeftEdge() { return m_pos.x - GetZoomedWidth()/2.0f; }; - virtual float GetRightEdge() { return m_pos.x + GetZoomedWidth()/2.0f; }; - virtual float GetTopEdge() { return m_pos.y - GetZoomedHeight()/2.0f; }; - virtual float GetBottomEdge() { return m_pos.y + GetZoomedHeight()/2.0f; }; + //virtual float GetLeftEdge() { return m_pos.x - GetZoomedWidth()/2.0f; }; + //virtual float GetRightEdge() { return m_pos.x + GetZoomedWidth()/2.0f; }; + //virtual float GetTopEdge() { return m_pos.y - GetZoomedHeight()/2.0f; }; + //virtual float GetBottomEdge() { return m_pos.y + GetZoomedHeight()/2.0f; }; enum StretchType { fit_inside, cover }; @@ -90,6 +98,26 @@ public: void StretchTo( LPRECT rect ); + + // effects + void SetEffectNone(); + void SetEffectBlinking( float fDeltaPercentPerSecond = 2.5, + D3DXCOLOR Color = D3DXCOLOR(0.5f,0.5f,0.5f,1), + D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) ); + void SetEffectCamelion( float fDeltaPercentPerSecond = 2.5, + D3DXCOLOR Color = D3DXCOLOR(0,0,0,1), + D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) ); + void SetEffectGlowing( float fDeltaPercentPerSecond = 2.5, + D3DXCOLOR Color = D3DXCOLOR(1,1,1,0.2f), + D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,0.8f) ); + void SetEffectWagging( float fWagRadians = 0.2, + float fWagPeriod = 2.0 ); + void SetEffectSpinning( float fRadsPerSpeed = 2.0 ); + void SetEffectVibrating( float fVibrationDistance = 5.0 ); + void SetEffectFlickering(); + Effect GetEffect() { return m_Effect; }; + + protected: void Init(); @@ -98,19 +126,43 @@ protected: D3DXVECTOR2 m_pos; // X-Y coordinate of where the center point will appear on screen D3DXVECTOR3 m_rotation; // X, Y, and Z m_rotation D3DXVECTOR2 m_scale; // X and Y zooming - D3DXCOLOR m_color; + D3DXCOLOR m_colorDiffuse; + D3DXCOLOR m_colorAdd; // start and end position for tweening - D3DXVECTOR2 m_start_pos, m_end_pos; - D3DXVECTOR3 m_start_rotation, m_end_rotation; - D3DXVECTOR2 m_start_scale, m_end_scale; - D3DXCOLOR m_start_color, m_end_color; + D3DXVECTOR2 m_start_pos, m_end_pos; + D3DXVECTOR3 m_start_rotation, m_end_rotation; + D3DXVECTOR2 m_start_scale, m_end_scale; + D3DXCOLOR m_start_colorDiffuse, m_end_colorDiffuse; + D3DXCOLOR m_start_colorAdd, m_end_colorAdd; // counters for tweening TweenType m_TweenType; float m_fTweenTime; // seconds between Start and End positions/zooms float m_fTimeIntoTween; // how long we have been tweening for + // effect + Effect m_Effect; + + // Counting variables for sprite effects: + // camelion and glowing: + float m_fPercentBetweenColors; + bool m_bTweeningTowardEndColor; // TRUE is fading toward end_color, FALSE if fading toward start_color + float m_fDeltaPercentPerSecond; // percentage change in tweening per second + + // wagging: + float m_fWagRadians; + float m_fWagPeriod; // seconds to complete a wag (back and forth) + float m_fWagTimer; // num of seconds into this wag + + // spinning: + float m_fSpinSpeed; // radians per second + + // vibrating: + float m_fVibrationDistance; + + // flickering: + bool m_bVisibleThisFrame; }; diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 2300b8e32a..024c3da994 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -20,7 +20,7 @@ void Background::LoadFromSong( Song& song ) { Sprite::LoadFromTexture( song.GetBackgroundPath() ); Sprite::StretchTo( CRect(0,0,640,480) ); - Sprite::SetColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) ); + Sprite::SetDiffuseColor( D3DXCOLOR(0.7f,0.7f,0.7f,1) ); CStringArray sVisualizationPaths; GetDirListing( sVisDir + "*.*", sVisualizationPaths ); diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index eaa23d5765..c630b8c2a7 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -180,7 +180,7 @@ Player::Player() m_sprGrayArrowGhost[c].SetRotation( m_ColumnToRotation[c] ); m_sprGrayArrowGhost[c].StopAnimating(); m_sprGrayArrowGhost[c].SetState( 1 ); - m_sprGrayArrowGhost[c].SetColor( D3DXCOLOR(1,1,1,0) ); + m_sprGrayArrowGhost[c].SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); // color arrows m_sprColorArrow[c].LoadFromSpriteFile( SPRITE_COLOR_ARROW ); @@ -212,16 +212,16 @@ Player::Player() } -void Player::SetX( int iX ) +void Player::SetX( float fX ) { - m_iArrowsCenterX = iX; + m_fArrowsCenterX = fX; - SetGrayArrowsX(iX); - SetColorArrowsX(iX); - SetJudgementX(iX); - SetComboX(iX); - SetScoreX(iX); - SetLifeMeterX(iX); + SetGrayArrowsX(fX); + SetColorArrowsX(fX); + SetJudgementX(fX); + SetComboX(fX); + SetScoreX(fX); + SetLifeMeterX(fX); } @@ -238,6 +238,8 @@ void Player::Update( const float &fDeltaTime, float fSongBeat, float fMaxBeatDif { //RageLog( "Player::Update(%f, %f, %f)", fDeltaTime, fSongBeat, fMaxBeatDifference ); + m_fSongBeat = fSongBeat; // save song beat + int iNumMisses = UpdateStepsMissedOlderThan( fSongBeat-fMaxBeatDifference ); if( iNumMisses > 0 ) { @@ -257,14 +259,14 @@ void Player::Update( const float &fDeltaTime, float fSongBeat, float fMaxBeatDif UpdateLifeMeter( fDeltaTime ); } -void Player::Draw( float fSongBeat ) +void Player::Draw() { DrawGrayArrows(); - DrawColorArrows( fSongBeat ); + DrawColorArrows(); DrawJudgement(); DrawCombo(); DrawScore(); - DrawLifeMeter( fSongBeat ); + DrawLifeMeter(); } @@ -420,9 +422,9 @@ ScoreSummary Player::GetScoreSummary() } -int Player::GetArrowColumnX( int iColNum ) +float Player::GetArrowColumnX( int iColNum ) { - return m_iArrowsCenterX + (iColNum - (m_iNumColumns-1)/2) * ARROW_SIZE; + return m_fArrowsCenterX + (iColNum - (m_iNumColumns-1)/2) * ARROW_SIZE; } void Player::UpdateGrayArrows( const float &fDeltaTime ) @@ -463,10 +465,10 @@ void Player::GrayArrowGhostStep( int index ) { m_sprGrayArrowGhost[index].SetXY( GetArrowColumnX(index), GRAY_ARROW_Y ); m_sprGrayArrowGhost[index].SetZoom( 1 ); - m_sprGrayArrowGhost[index].SetColor( D3DXCOLOR(1,1,0.5f,1) ); + m_sprGrayArrowGhost[index].SetDiffuseColor( D3DXCOLOR(1,1,0.5f,1) ); m_sprGrayArrowGhost[index].BeginTweening( 0.3f ); m_sprGrayArrowGhost[index].SetTweenZoom( 1.5 ); - m_sprGrayArrowGhost[index].SetTweenColor( D3DXCOLOR(1,1,0.5f,0) ); + m_sprGrayArrowGhost[index].SetTweenDiffuseColor( D3DXCOLOR(1,1,0.5f,0) ); } void Player::UpdateColorArrows( const float &fDeltaTime ) @@ -474,15 +476,15 @@ void Player::UpdateColorArrows( const float &fDeltaTime ) } -void Player::DrawColorArrows( float fSongBeat ) +void Player::DrawColorArrows() { //RageLog( "ColorArrows::Draw(%f)", fSongBeat ); - int iBaseFrameNo = (int)(fSongBeat*2.5) % 12; // 2.5 is a "fudge number" :-) This should be based on BPM + int iBaseFrameNo = (int)(m_fSongBeat*2.5) % 12; // 2.5 is a "fudge number" :-) This should be based on BPM - int iIndexFirstArrowToDraw = BeatToStepIndex( fSongBeat - 2.0f ); // 2 beats earlier + int iIndexFirstArrowToDraw = BeatToStepIndex( m_fSongBeat - 2.0f ); // 2 beats earlier if( iIndexFirstArrowToDraw < 0 ) iIndexFirstArrowToDraw = 0; - int iIndexLastArrowToDraw = BeatToStepIndex( fSongBeat + 7.0f ); // 7 beats later + int iIndexLastArrowToDraw = BeatToStepIndex( m_fSongBeat + 7.0f ); // 7 beats later //RageLog( "Drawing elements %d through %d", iIndexFirstArrowToDraw, iIndexLastArrowToDraw ); @@ -490,7 +492,7 @@ void Player::DrawColorArrows( float fSongBeat ) { if( m_LeftToStepOn[i] != 0 ) // this step is not yet complete { - int iYPos = GetColorArrowYPos( i, fSongBeat ); + float fYPos = GetColorArrowYPos( i, m_fSongBeat ); // calculate which frame to display int iFrameNo = iBaseFrameNo + m_iColorArrowFrameOffset[i]; @@ -500,7 +502,7 @@ void Player::DrawColorArrows( float fSongBeat ) 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_sprColorArrow[c].SetY( iYPos ); + m_sprColorArrow[c].SetY( fYPos ); m_sprColorArrow[c].SetState( iFrameNo ); m_sprColorArrow[c].Draw(); } @@ -519,7 +521,7 @@ void Player::DrawColorArrows( float fSongBeat ) -int Player::GetColorArrowYPos( int iStepIndex, float fSongBeat ) +float Player::GetColorArrowYPos( int iStepIndex, float fSongBeat ) { float fBeatsUntilStep = StepIndexToBeat( iStepIndex ) - fSongBeat; return (int)(fBeatsUntilStep * ARROW_GAP) + GRAY_ARROW_Y; @@ -629,14 +631,14 @@ void Player::UpdateLifeMeter( const float &fDeltaTime ) m_sprLifeMeterPills.Update( fDeltaTime ); } -void Player::DrawLifeMeter( float fSongBeat ) +void Player::DrawLifeMeter() { - float fBeatPercentage = fSongBeat - (int)fSongBeat; + float fBeatPercentage = m_fSongBeat - (int)m_fSongBeat; int iOffsetStart = roundf( LIEFMETER_NUM_PILLS*fBeatPercentage ); m_sprLifeMeterFrame.Draw(); - float iX = m_sprLifeMeterFrame.GetLeftEdge() + 27; + float iX = m_sprLifeMeterFrame.GetX() - m_sprLifeMeterFrame.GetZoomedWidth()/2 + 27; int iNumPills = (int)(m_sprLifeMeterPills.GetNumStates() * m_fLifePercentage); int iPillWidth = m_sprLifeMeterPills.GetZoomedWidth(); @@ -724,16 +726,16 @@ void Player::ChangeScore( StepScore score, int iCurCombo ) float M = iCurCombo/4.0f; - int iScoreToAdd = 0; + float fScoreToAdd = 0; switch( score ) { case miss: break; case boo: break; - case good: iScoreToAdd = M * 100 + 100; break; - case great: iScoreToAdd = M * M * 100 + 300; break; - case perfect: iScoreToAdd = M * M * 300 + 500; break; + case good: fScoreToAdd = M * 100 + 100; break; + case great: fScoreToAdd = M * M * 100 + 300; break; + case perfect: fScoreToAdd = M * M * 300 + 500; break; } - m_fScore += iScoreToAdd; + m_fScore += fScoreToAdd; ASSERT( m_fScore > 0 ); diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 4c5b4f5c3a..8b746b7b29 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -27,9 +27,9 @@ public: Player(); void SetSteps( const Steps& newSteps ); - void SetX( int iX ); + void SetX( float fX ); void Update( const float &fDeltaTime, float fSongBeat, float fMaxBeatDifference ); - void Draw( float fSongBeat ); + void Draw(); ScoreSummary GetScoreSummary(); @@ -40,8 +40,9 @@ protected: void CheckForCompleteStep( float fSongBeat, Step player_step, float fMaxBeatDiff ); void OnCompleteStep( float fSongBeat, Step player_step, float fMaxBeatDiff, int iStepIndex ); - int m_iCurCombo; - int m_iMaxCombo; + int m_iCurCombo; + int m_iMaxCombo; + float m_fSongBeat; enum StepScore{ none, perfect, great, good, boo, miss }; enum StepTiming{ no_timing, early, late }; @@ -53,19 +54,19 @@ protected: // common to color and gray arrows - int m_iArrowsCenterX; + float m_fArrowsCenterX; int m_iNumColumns; // will vary depending on the number panels (4,6,8,etc) CMap m_StepToColumnNumber; CMap m_ColumnNumberToStep; CMap m_ColumnToRotation; - int GetArrowColumnX( int iColNum ); + float GetArrowColumnX( int iColNum ); // color arrows void SetColorArrowsX( int iX ); void UpdateColorArrows( const float& fDeltaTime ); - int GetColorArrowYPos( int iStepIndex, float fSongBeat ); - void DrawColorArrows( float fSongBeat ); + float GetColorArrowYPos( int iStepIndex, float fSongBeat ); + void DrawColorArrows(); Sprite m_sprColorArrow[MAX_NUM_COLUMNS]; int m_iColorArrowFrameOffset[MAX_STEP_ELEMENTS]; @@ -92,14 +93,14 @@ protected: void UpdateCombo( const float& fDeltaTime ); void DrawCombo(); void SetCombo( int iNum ); - BOOL m_bComboVisible; + bool m_bComboVisible; Sprite m_sprCombo; SpriteSequence m_ComboNumber; // life meter void SetLifeMeterX( int iX ); void UpdateLifeMeter( const float& fDeltaTime ); - void DrawLifeMeter( float fSongBeat ); + void DrawLifeMeter(); void ChangeLife( StepScore score ); public: float GetLifePercentage() { return m_fLifePercentage; }; diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 4eea409b9f..85b3b64a9f 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -52,7 +52,7 @@ Sprite::~Sprite() } -BOOL Sprite::LoadFromTexture( CString sTexturePath ) +bool Sprite::LoadFromTexture( CString sTexturePath ) { RageLog( ssprintf("Sprite::LoadFromTexture(%s)", sTexturePath) ); @@ -68,7 +68,7 @@ BOOL Sprite::LoadFromTexture( CString sTexturePath ) // Delay0000=1.0 // Frame0001=3 // Delay0000=2.0 -BOOL Sprite::LoadFromSpriteFile( CString sSpritePath ) +bool Sprite::LoadFromSpriteFile( CString sSpritePath ) { RageLog( ssprintf("Sprite::LoadFromSpriteFile(%s)", sSpritePath) ); @@ -119,7 +119,7 @@ BOOL Sprite::LoadFromSpriteFile( CString sSpritePath ) return TRUE; } -BOOL Sprite::LoadTexture( CString sTexturePath ) +bool Sprite::LoadTexture( CString sTexturePath ) { if( m_sTexturePath != "" ) // If there was a previous bitmap... TM->UnloadTexture( m_sTexturePath ); // Unload it. @@ -131,8 +131,8 @@ BOOL Sprite::LoadTexture( CString sTexturePath ) assert( m_pTexture != NULL ); // the size of the sprite is the size of the image before it was scaled - SetWidth( (FLOAT)m_pTexture->GetSourceFrameWidth() ); - SetHeight( (FLOAT)m_pTexture->GetSourceFrameHeight() ); + SetWidth( (float)m_pTexture->GetSourceFrameWidth() ); + SetHeight( (float)m_pTexture->GetSourceFrameHeight() ); // Assume the frames of this animation play in sequential order with 0.2 second delay. for( UINT i=0; iGetNumFrames(); i++ ) @@ -156,7 +156,7 @@ void Sprite::PrintDebugInfo() } -void Sprite::Update( const FLOAT &fDeltaTime ) +void Sprite::Update( const float &fDeltaTime ) { //PrintDebugInfo(); @@ -178,48 +178,7 @@ void Sprite::Update( const FLOAT &fDeltaTime ) } } - // update SpriteEffect - switch( m_Effect ) - { - case no_effect: - break; - case blinking: - case camelion: - case glowing: - if( m_bTweeningTowardEndColor ) { - m_fPercentBetweenColors += m_fDeltaPercentPerSecond * fDeltaTime; - if( m_fPercentBetweenColors > 1.0f ) { - m_fPercentBetweenColors = 1.0f; - m_bTweeningTowardEndColor = FALSE; - } - } - else { // !m_bTweeningTowardEndColor - m_fPercentBetweenColors -= m_fDeltaPercentPerSecond * fDeltaTime; - if( m_fPercentBetweenColors < 0.0f ) { - m_fPercentBetweenColors = 0.0f; - m_bTweeningTowardEndColor = TRUE; - } - } - case wagging: - m_fWagTimer += fDeltaTime; - if( m_fWagTimer > m_fWagPeriod ) - m_fWagTimer -= m_fWagPeriod; - break; - case spinning: - FLOAT rotation; - rotation = GetRotation(); - rotation += m_fSpinSpeed * fDeltaTime; - if( rotation > 2.0f * D3DX_PI ) - rotation -= 2.0f * D3DX_PI; - else if( rotation < 0.0f ) - rotation += 2.0f * D3DX_PI; - SetRotation( rotation ); - break; - case vibrating: - break; - case flickering: - break; - } + } @@ -227,6 +186,8 @@ void Sprite::Update( const FLOAT &fDeltaTime ) void Sprite::Draw() { + Actor::Draw(); // set up our world matrix + if( m_pTexture == NULL ) return; @@ -238,11 +199,9 @@ void Sprite::Draw() pTexCoordRect = m_pTexture->GetTextureCoordRect( uFrameNo ); } - D3DXCOLOR color = m_color; - D3DXVECTOR2 pos = m_pos; - D3DXVECTOR3 rotation = m_rotation; - D3DXVECTOR2 scale = m_scale; - bool bBlendAdd = false; + + D3DXCOLOR colorDiffuse = m_colorDiffuse; + D3DXCOLOR colorAdd = m_colorAdd; // update properties based on SpriteEffects switch( m_Effect ) @@ -250,65 +209,66 @@ void Sprite::Draw() case no_effect: break; case blinking: - color = m_bTweeningTowardEndColor ? m_start_color : m_end_color; + colorDiffuse = m_bTweeningTowardEndColor ? m_start_colorDiffuse : m_end_colorDiffuse; break; case camelion: - color = m_start_color*m_fPercentBetweenColors + m_end_color*(1.0f-m_fPercentBetweenColors); + colorDiffuse = m_start_colorDiffuse*m_fPercentBetweenColors + m_end_colorDiffuse*(1.0f-m_fPercentBetweenColors); break; case glowing: - color = m_start_color*m_fPercentBetweenColors + m_end_color*(1.0f-m_fPercentBetweenColors); - bBlendAdd = true; + colorAdd = m_start_colorAdd*m_fPercentBetweenColors + m_end_colorAdd*(1.0f-m_fPercentBetweenColors); break; case wagging: - rotation.z = m_fWagRadians * (FLOAT)sin( - (m_fWagTimer / m_fWagPeriod) // percent through wag - * 2.0 * D3DX_PI ); break; case spinning: // nothing special needed break; case vibrating: - pos.x += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); - pos.y += m_fVibrationDistance * randomf(-1.0f, 1.0f) * GetZoom(); break; case flickering: m_bVisibleThisFrame = !m_bVisibleThisFrame; - if( m_bVisibleThisFrame ) - return; // don't draw the frame + if( !m_bVisibleThisFrame ) + colorDiffuse = D3DXCOLOR(0,0,0,0); // don't draw the frame break; } - // make a 1x1 rect centered at the origin + // make the object in logical units centered at the origin LPDIRECT3DVERTEXBUFFER8 pVB = SCREEN->GetVertexBuffer(); CUSTOMVERTEX* v; pVB->Lock( 0, 0, (BYTE**)&v, 0 ); - v[0].p = D3DXVECTOR3( -0.5f, 0.5f, 0 ); // bottom left - v[1].p = D3DXVECTOR3( -0.5f, -0.5f, 0 ); // top left - v[2].p = D3DXVECTOR3( 0.5f, 0.5f, 0 ); // bottom right - v[3].p = D3DXVECTOR3( 0.5f, -0.5f, 0 ); // top right + float fHalfSizeX = m_size.x/2; + float fHalfSizeY = m_size.y/2; + + v[0].p = D3DXVECTOR3( -fHalfSizeX, fHalfSizeY, 0 ); // bottom left + v[1].p = D3DXVECTOR3( -fHalfSizeX, -fHalfSizeY, 0 ); // top left + v[2].p = D3DXVECTOR3( fHalfSizeX, fHalfSizeY, 0 ); // bottom right + v[3].p = D3DXVECTOR3( fHalfSizeX, -fHalfSizeY, 0 ); // top right v[0].tu = pTexCoordRect->left; v[0].tv = pTexCoordRect->bottom; // bottom left v[1].tu = pTexCoordRect->left; v[1].tv = pTexCoordRect->top; // top left v[2].tu = pTexCoordRect->right; v[2].tv = pTexCoordRect->bottom; // bottom right v[3].tu = pTexCoordRect->right; v[3].tv = pTexCoordRect->top; // top right - v[0].color = v[1].color = v[2].color = v[3].color = color; + v[0].color = v[1].color = v[2].color = v[3].color = colorDiffuse; pVB->Unlock(); + ////////////////////// + // render the diffuse pass + ////////////////////// + // set texture and alpha properties LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice(); pd3dDevice->SetTexture( 0, m_pTexture->GetD3DTexture() ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); - pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//bBlendAdd ? D3DTOP_ADD : D3DTOP_MODULATE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR ); //pd3dDevice->SetRenderState( D3DRS_SRCBLEND, bBlendAdd ? D3DBLEND_ONE : D3DBLEND_SRCALPHA ); @@ -317,128 +277,32 @@ void Sprite::Draw() pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - // calculate transforms - D3DXMATRIX matWorld, matTemp; - D3DXMatrixIdentity( &matWorld ); // initialize world - D3DXMatrixScaling( &matTemp, m_size.x, m_size.y, 1 ); // scale to the native height and width - matWorld *= matTemp; - D3DXMatrixScaling( &matTemp, scale.x, scale.y, 1 ); // add in the zoom - matWorld *= matTemp; - D3DXMatrixRotationYawPitchRoll( &matTemp, rotation.y, rotation.x, rotation.z ); // add in the rotation - matWorld *= matTemp; - D3DXMatrixTranslation( &matTemp, pos.x, pos.y, 0 ); // add in the translation - matWorld *= matTemp; - D3DXMatrixTranslation( &matTemp, -0.5f, -0.5f, 0 ); // shift to align texels with pixels - matWorld *= matTemp; - pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); - - D3DXMATRIX matView; - D3DXMatrixIdentity( &matView ); - pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); - - D3DXMATRIX matProj; - D3DXMatrixOrthoOffCenterLH( &matProj, 0, 640, 480, 0, -100, 100 ); - pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); - - // finally! Pump those triangles! pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX ); pd3dDevice->SetStreamSource( 0, pVB, sizeof(CUSTOMVERTEX) ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); + ////////////////////// + // render the diffuse pass + ////////////////////// + if( colorAdd.a == 0 ) // no need to render an add pass + return; + pVB->Lock( 0, 0, (BYTE**)&v, 0 ); -/* WORKS! - - LPDIRECT3DVERTEXBUFFER8 pVB2 = NULL; // Buffer to hold vertices - - // A structure for our custom vertex type - struct CUSTOMVERTEX - { - FLOAT x, y, z; // The untransformed, 3D position for the vertex - DWORD color; // The vertex color - }; - - // Our custom FVF, which describes our custom vertex structure - #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE) - - // Initialize three vertices for rendering a triangle - CUSTOMVERTEX g_Vertices[] = - { - { -15.0f,-15.0f, 0.0f, 0xffff0000, }, - { 15.0f,-15.0f, 0.0f, 0xff0000ff, }, - { 00.0f, 15.0f, 0.0f, 0xffffffff, }, - }; - - // Create the vertex buffer. - if( FAILED( pd3dDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX), - 0, D3DFVF_CUSTOMVERTEX, - D3DPOOL_DEFAULT, &pVB2 ) ) ) - { - return; - } - - // Turn off culling, so we see the front and back of the triangle - pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); - - // Turn off D3D lighting, since we are providing our own vertex colors - pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); - - - // Fill the vertex buffer. - void* pVertices; - if( FAILED( pVB2->Lock( 0, sizeof(g_Vertices), (BYTE**)&pVertices, 0 ) ) ) - return; - memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); - pVB2->Unlock(); - - - // For our world matrix, we will just rotate the object about the y-axis. - //D3DXMATRIX matWorld; - D3DXMatrixRotationY( &matWorld, GetTickCount()/150.0f ); - pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); - - // Set up our view matrix. A view matrix can be defined given an eye point, - // a point to lookat, and a direction for which way is up. Here, we set the - // eye five units back along the z-axis and up three units, look at the - // origin, and define "up" to be in the y-direction. - //D3DXMATRIX matView; - //D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 3.0f,-5.0f ), - // &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ), - // &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) ); - D3DXMatrixIdentity( &matView ); - pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); - - // For the projection matrix, we set up a perspective transform (which - // transforms geometry from 3D view space to 2D viewport space, with - // a perspective divide making objects smaller in the distance). To build - // a perpsective transform, we need the field of view (1/4 pi is common), - // the aspect ratio, and the near and far clipping planes (which define at - // what distances geometry should be no longer be rendered). - //D3DXMATRIX matProj; - //D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f ); - //D3DXMatrixOrthoLH( &matProj, 640, -480, -100, 100 ); - D3DXMatrixOrthoOffCenterLH( &matProj, 0, 320, 480, 0, -100, 100 ); -// D3DXMatrixOrthoOffCenterLH( &matProj, -20, 20, 20, -20, -100, 100 ); - - pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); - - // Render the vertex buffer contents - pd3dDevice->SetStreamSource( 0, pVB2, sizeof(CUSTOMVERTEX) ); - pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX ); - pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 ); - - - - - if( pVB2 != NULL ) - pVB2->Release(); -*/ - - - + v[0].color = v[1].color = v[2].color = v[3].color = colorAdd; + + pVB->Unlock(); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + + pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); } @@ -456,62 +320,4 @@ void Sprite::SetCustomSrcRect( FRECT new_texcoord_frect ) m_CustomTexCoordRect = new_texcoord_frect; } -void Sprite::SetEffectNone() -{ - m_Effect = no_effect; - //m_color = D3DXCOLOR( 1.0,1.0,1.0,1.0 ); -} -void Sprite::SetEffectBlinking( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) -{ - m_Effect = blinking; - m_start_color = Color; - m_end_color = Color2; - //m_fPercentBetweenColors = 0.0; - //m_bTweeningTowardEndColor = TRUE; - m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; -} - -void Sprite::SetEffectCamelion( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) -{ - m_Effect = camelion; - m_start_color = Color; - m_end_color = Color2; - //m_fPercentBetweenColors = 0.0; - //m_bTweeningTowardEndColor = TRUE; - m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; -} - -void Sprite::SetEffectGlowing( FLOAT fDeltaPercentPerSecond, D3DXCOLOR Color, D3DXCOLOR Color2 ) -{ - m_Effect = glowing; - m_start_color = Color; - m_end_color = Color2; - //m_fPercentBetweenColors = 0.0; - //m_bTweeningTowardEndColor = TRUE; - m_fDeltaPercentPerSecond = fDeltaPercentPerSecond; -} - -void Sprite::SetEffectWagging( FLOAT fWagRadians, FLOAT fWagPeriod ) -{ - m_Effect = wagging; - m_fWagRadians = fWagRadians; - m_fWagPeriod = fWagPeriod; -} - -void Sprite::SetEffectSpinning( FLOAT fSpinSpeed /*radians per second*/ ) -{ - m_Effect = spinning; - m_fSpinSpeed = fSpinSpeed; -} - -void Sprite::SetEffectVibrating( FLOAT fVibrationDistance ) -{ - m_Effect = vibrating; - m_fVibrationDistance = fVibrationDistance; -} - -void Sprite::SetEffectFlickering() -{ - m_Effect = flickering; -} diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index 40b667d15c..b5a8411523 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -29,20 +29,15 @@ public: virtual ~Sprite(); - enum SpriteEffect { no_effect, - blinking, camelion, glowing, - wagging, spinning, - vibrating, flickering - }; - BOOL LoadFromTexture( CString sTexturePath ); - BOOL LoadFromSpriteFile( CString sSpritePath ); + bool LoadFromTexture( CString sTexturePath ); + bool LoadFromSpriteFile( CString sSpritePath ); void PrintDebugInfo(); virtual void Draw(); - virtual void Update( const FLOAT &fDeltaTime ); + virtual void Update( const float &fDeltaTime ); void StartAnimating() { m_bIsAnimating = TRUE; }; void StopAnimating() { m_bIsAnimating = FALSE; }; @@ -55,65 +50,25 @@ public: void SetCustomSrcRect( FRECT new_texcoord_frect ); // for cropping - void SetEffectNone(); - void SetEffectBlinking( FLOAT fDeltaPercentPerSecond = 2.5, - D3DXCOLOR Color = D3DXCOLOR(0.5f,0.5f,0.5f,1), - D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) ); - void SetEffectCamelion( FLOAT fDeltaPercentPerSecond = 2.5, - D3DXCOLOR Color = D3DXCOLOR(0,0,0,1), - D3DXCOLOR Color2 = D3DXCOLOR(1,1,1,1) ); - void SetEffectGlowing( FLOAT fDeltaPercentPerSecond = 2.5, - D3DXCOLOR Color = D3DXCOLOR(0.2f,0.2f,0.2f,0), - D3DXCOLOR Color2 = D3DXCOLOR(0.8f,0.8f,0.8f,0) ); - void SetEffectWagging( FLOAT fWagRadians = 0.2, - FLOAT fWagPeriod = 2.0 ); - void SetEffectSpinning( FLOAT fRadsPerSpeed = 2.0 ); - void SetEffectVibrating( FLOAT fVibrationDistance = 5.0 ); - void SetEffectFlickering(); - SpriteEffect GetEffect() { return m_Effect; }; protected: void Init(); - BOOL LoadTexture( CString sTexture ); + bool LoadTexture( CString sTexture ); CString m_sSpritePath; LPRageTexture m_pTexture; CString m_sTexturePath; UINT m_uFrame[MAX_SPRITE_STATES]; // array of indicies into m_rectBitmapFrames - FLOAT m_fDelay[MAX_SPRITE_STATES]; + float m_fDelay[MAX_SPRITE_STATES]; UINT m_uNumStates; UINT m_uCurState; - BOOL m_bIsAnimating; - FLOAT m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame + bool m_bIsAnimating; + float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame - BOOL m_bUsingCustomTexCoordRect; + bool m_bUsingCustomTexCoordRect; FRECT m_CustomTexCoordRect; - - SpriteEffect m_Effect; - - // Counting variables for sprite effects: - // camelion and glowing: -// D3DXCOLOR m_Color2; - FLOAT m_fPercentBetweenColors; - BOOL m_bTweeningTowardEndColor; // TRUE is fading toward end_color, FALSE if fading toward start_color - FLOAT m_fDeltaPercentPerSecond; // percentage change in tweening per second - - // wagging: - FLOAT m_fWagRadians; - FLOAT m_fWagPeriod; // seconds to complete a wag (back and forth) - FLOAT m_fWagTimer; // num of seconds into this wag - - // spinning: - FLOAT m_fSpinSpeed; // radians per second - - // vibrating: - FLOAT m_fVibrationDistance; - - // flickering: - BOOL m_bVisibleThisFrame; - }; diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index f1502ae6fe..428ee07dc6 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -447,11 +447,29 @@ void Render() break; case S_OK: - // draw the game - WM->Draw(); + { + // set texture and alpha properties + LPDIRECT3DDEVICE8 pd3dDevice = SCREEN->GetDevice(); + + // calculate view and projection transforms + + D3DXMATRIX matView; + D3DXMatrixIdentity( &matView ); + pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); + + D3DXMATRIX matProj; + D3DXMatrixOrthoOffCenterLH( &matProj, 0, 640, 480, 0, -100, 100 ); + pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); + + D3DXCOLOR colorDiffuse = D3DXCOLOR(1,1,1,1); + D3DXCOLOR colorAdd = D3DXCOLOR(0,0,0,0); + + // draw the game + WM->Draw(); - SCREEN->EndFrame(); + SCREEN->EndFrame(); + } break; } } diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index 2bd1876f0e..a5406afccc 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -40,10 +40,10 @@ public: virtual void CloseWipingRight(WindowMessage send_when_done ); virtual void CloseWipingLeft( WindowMessage send_when_done ); - BOOL IsClosed() { return m_TransitionState == closed; }; - BOOL IsClosing() { return m_TransitionState == closing_right || m_TransitionState == closing_left; }; + bool IsClosed() { return m_TransitionState == closed; }; + bool IsClosing() { return m_TransitionState == closing_right || m_TransitionState == closing_left; }; - VOID SetTransitionTime( FLOAT fNewTransitionTime ) { m_fTransitionTime = fNewTransitionTime; }; + void SetTransitionTime( FLOAT fNewTransitionTime ) { m_fTransitionTime = fNewTransitionTime; }; void SetColor( D3DXCOLOR new_color ) { m_Color = new_color; }; void SetCloseWipingRightSound( CString sSoundPath ); @@ -56,13 +56,13 @@ protected: closing_right, closing_left }; TransitionState m_TransitionState; - FLOAT m_fTransitionTime; - FLOAT m_fPercentThroughTransition; + float m_fTransitionTime; + float m_fPercentThroughTransition; WindowMessage m_MessageToSendWhenDone; - BOOL m_bPlayCloseWipingRightSound; - BOOL m_bPlayCloseWipingLeftSound; + bool m_bPlayCloseWipingRightSound; + bool m_bPlayCloseWipingLeftSound; HSAMPLE m_hCloseWipingRightSound; HSAMPLE m_hCloseWipingLeftSound; diff --git a/stepmania/src/TransitionFade.cpp b/stepmania/src/TransitionFade.cpp index 828f9497db..8ecc7f165d 100644 --- a/stepmania/src/TransitionFade.cpp +++ b/stepmania/src/TransitionFade.cpp @@ -35,7 +35,7 @@ TransitionFade::~TransitionFade() void TransitionFade::Draw() { - FLOAT fPercentageOpaque; + float fPercentageOpaque; switch( m_TransitionState ) { case opened: diff --git a/stepmania/src/TransitionStarWipe.cpp b/stepmania/src/TransitionStarWipe.cpp index 6fc9fb2d99..49d59de3d1 100644 --- a/stepmania/src/TransitionStarWipe.cpp +++ b/stepmania/src/TransitionStarWipe.cpp @@ -39,7 +39,7 @@ void TransitionStarWipe::Draw() return; } - FLOAT fPercentOpen; + float fPercentOpen; switch( m_TransitionState ) { case opening_right: