From 78d66da3d3d39fa8ad8b849f45d1d92f9c4c2883 Mon Sep 17 00:00:00 2001 From: Andrew Livy Date: Sun, 12 Jan 2003 18:41:24 +0000 Subject: [PATCH] BGAnimation Layer now has a -really poor- tweening mechanism. It barely takes into account -time-. Pump How To Play BGA Screen now kinda complete, and uses the mechanism (this is a for a demonstration on the kinds of things we need to support in BGALayer to make truly unique animations, it shouldn't be carved in stone and used as THE BGA Tweening system as it is.) --- stepmania/src/BGAnimationLayer.cpp | 69 +++++++++++++++++++++++++++++- stepmania/src/BGAnimationLayer.h | 4 ++ stepmania/src/ScreenSelectMusic.h | 2 +- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/stepmania/src/BGAnimationLayer.cpp b/stepmania/src/BGAnimationLayer.cpp index e93b606a43..8c92733490 100644 --- a/stepmania/src/BGAnimationLayer.cpp +++ b/stepmania/src/BGAnimationLayer.cpp @@ -102,6 +102,9 @@ void BGAnimationLayer::LoadFromAniLayerFile( CString sPath, CString sSongBGPath m_TweenX = 0.0; m_TweenY = 0.0; m_TweenSpeed = 0; + m_TweenState = 0; + m_TweenPassedX = 0; + m_TweenPassedY = 0; if( sPath.Find("usesongbg") != -1 ) { @@ -567,10 +570,74 @@ void BGAnimationLayer::Update( float fDeltaTime ) // Going as fast as m_TweenSpeed specifies. // however, TWEEN falls over on its face at this point. // Lovely. - + // Instead: Manual tweening. Blah. + m_TweenState = 1; + if(m_PosX == m_TweenX) + { + m_TweenPassedX = 1; + } + if(m_PosY == m_TweenY) + { + m_TweenPassedY = 1; + } } } + if(m_TweenState) // A FAR from perfect Tweening Mechanism. + { + if(m_TweenPassedY != 1) // Check to see if we still need to Tween Along the Y Axis + { + if(m_Sprites[0].GetY() < m_TweenY) // it needs to travel down + { + // Speed = Distance / Time.... + // Take away from the current position... the distance it has to travel divided by the time they want it done in... + m_Sprites[0].SetY(m_Sprites[0].GetY() + ((m_TweenY - m_PosY)/(m_TweenSpeed*60))); + + if(m_Sprites[0].GetY() > m_TweenY) // passed the location we wanna go to? + { + m_Sprites[0].SetY(m_TweenY); // set it to the exact location we want + m_TweenPassedY = 1; // say we passed it. + } + } + else // travelling up + { + m_Sprites[0].SetY(m_Sprites[0].GetY() - ((m_TweenY + m_PosY)/(m_TweenSpeed*60))); + + if(m_Sprites[0].GetY() < m_TweenY) + { + m_Sprites[0].SetY(m_TweenY); + m_TweenPassedY = 1; + } + } + } + + if(m_TweenPassedX != 1) // Check to see if we still need to Tween Along the X Axis + { + if(m_Sprites[0].GetX() < m_TweenX) // it needs to travel right + { + m_Sprites[0].SetX(m_Sprites[0].GetX() + ((m_TweenX - m_PosX)/(m_TweenSpeed*60))); + if(m_Sprites[0].GetX() > m_TweenX) + { + m_Sprites[0].SetX(m_TweenX); + m_TweenPassedX = 1; + } + } + else // travelling left + { + m_Sprites[0].SetX(m_Sprites[0].GetX() - ((m_TweenX + m_PosX)/(m_TweenSpeed*60))); + if(m_Sprites[0].GetX() < m_TweenX) + { + m_Sprites[0].SetX(m_TweenX); + m_TweenPassedX = 1; + } + } + } + + if(m_TweenPassedY == 1 && m_TweenPassedX == 1) // totally passed both X and Y? Stop tweening. + { + m_TweenState = 0; + } + } if(m_ShowTime != 0 && !(m_ShowTime < 0)) { diff --git a/stepmania/src/BGAnimationLayer.h b/stepmania/src/BGAnimationLayer.h index 4bdb08621f..9559922ec5 100644 --- a/stepmania/src/BGAnimationLayer.h +++ b/stepmania/src/BGAnimationLayer.h @@ -93,6 +93,10 @@ protected: float m_TweenX; float m_TweenY; float m_TweenSpeed; + + int m_TweenState; + int m_TweenPassedX; + int m_TweenPassedY; }; #endif diff --git a/stepmania/src/ScreenSelectMusic.h b/stepmania/src/ScreenSelectMusic.h index 96b054faa8..bf93168505 100644 --- a/stepmania/src/ScreenSelectMusic.h +++ b/stepmania/src/ScreenSelectMusic.h @@ -67,7 +67,7 @@ protected: Sprite m_sprDifficultyFrame[NUM_PLAYERS]; DifficultyIcon m_DifficultyIcon[NUM_PLAYERS]; Sprite m_AutoGenIcon[NUM_PLAYERS]; - GrooveRadar m_GrooveRadar; + GrooveRadar m_GrooveRadar; // BitmapText m_textPlayerOptions[NUM_PLAYERS]; BitmapText m_textSongOptions; OptionIconRow m_OptionIconRow[NUM_PLAYERS];