Clapm the fast-moving wheel sound effects; bumps speed from 80fps
to 130fps for me. (I think it was starting over a hundred at a time ...) The "random" effect was experimental. I liked the bounce, but the effect of pulling in random songs as it spun was hacky and not too important (and a little buggy). Random is now like roulette, except 1: it's shuffled, 2: it moves in reverse, and 3: it stops with a bounce instead of shifts, and 4: it spins twice as fast. Currently, the bounce is a little bumpy; that's loading the sample music, I think.
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
#define NUM_SECTION_COLORS THEME->GetMetricI("MusicWheel","NumSectionColors")
|
#define NUM_SECTION_COLORS THEME->GetMetricI("MusicWheel","NumSectionColors")
|
||||||
#define SECTION_COLORS( i ) THEME->GetMetricC("MusicWheel",ssprintf("SectionColor%d",i+1))
|
#define SECTION_COLORS( i ) THEME->GetMetricC("MusicWheel",ssprintf("SectionColor%d",i+1))
|
||||||
|
|
||||||
|
const float WHEEL_SOUND_DELAY = 1/16.f;
|
||||||
float g_fItemSpacingY, g_fItemCurveX; // cache
|
float g_fItemSpacingY, g_fItemCurveX; // cache
|
||||||
|
|
||||||
inline RageColor GetNextSectionColor() {
|
inline RageColor GetNextSectionColor() {
|
||||||
@@ -819,16 +820,6 @@ void MusicWheel::Update( float fDeltaTime )
|
|||||||
if(m_TimeBeforeMovingBegins == 0 && m_WheelState != STATE_LOCKED &&
|
if(m_TimeBeforeMovingBegins == 0 && m_WheelState != STATE_LOCKED &&
|
||||||
fabsf(m_fPositionOffsetFromSelection) < 0.5f)
|
fabsf(m_fPositionOffsetFromSelection) < 0.5f)
|
||||||
{
|
{
|
||||||
if(m_WheelState == STATE_RANDOM_SPINNING && !m_iSwitchesLeftInSpinDown)
|
|
||||||
{
|
|
||||||
// m_fPositionOffsetFromSelection = max(m_fPositionOffsetFromSelection, 0.3f);
|
|
||||||
m_Moving = 0;
|
|
||||||
m_WheelState = STATE_LOCKED;
|
|
||||||
m_soundStart.Play();
|
|
||||||
m_fLockedWheelVelocity = 0;
|
|
||||||
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// spin as fast as possible
|
// spin as fast as possible
|
||||||
if(m_Moving == 1) NextMusic();
|
if(m_Moving == 1) NextMusic();
|
||||||
else PrevMusic();
|
else PrevMusic();
|
||||||
@@ -837,7 +828,6 @@ void MusicWheel::Update( float fDeltaTime )
|
|||||||
m_iSwitchesLeftInSpinDown--;
|
m_iSwitchesLeftInSpinDown--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// update wheel state
|
// update wheel state
|
||||||
m_fTimeLeftInState -= fDeltaTime;
|
m_fTimeLeftInState -= fDeltaTime;
|
||||||
@@ -1056,7 +1046,15 @@ void MusicWheel::PrevMusic()
|
|||||||
|
|
||||||
m_fPositionOffsetFromSelection -= 1;
|
m_fPositionOffsetFromSelection -= 1;
|
||||||
|
|
||||||
|
/* If we're moving fast, only play the change music occasionally.
|
||||||
|
* If we play full throttle, we'll play as many as the sound driver
|
||||||
|
* will do, which is slow. This doesn't sound too great, though
|
||||||
|
* it's better than the intermittent effect we had before ... */
|
||||||
|
if(!m_Moving || m_MovingSoundTimer.PeekDeltaTime() >= WHEEL_SOUND_DELAY)
|
||||||
|
{
|
||||||
|
m_MovingSoundTimer.GetDeltaTime();
|
||||||
m_soundChangeMusic.Play();
|
m_soundChangeMusic.Play();
|
||||||
|
}
|
||||||
|
|
||||||
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
|
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
|
||||||
}
|
}
|
||||||
@@ -1095,7 +1093,11 @@ void MusicWheel::NextMusic()
|
|||||||
|
|
||||||
m_fPositionOffsetFromSelection += 1;
|
m_fPositionOffsetFromSelection += 1;
|
||||||
|
|
||||||
|
if(!m_Moving || m_MovingSoundTimer.PeekDeltaTime() >= WHEEL_SOUND_DELAY)
|
||||||
|
{
|
||||||
|
m_MovingSoundTimer.GetDeltaTime();
|
||||||
m_soundChangeMusic.Play();
|
m_soundChangeMusic.Play();
|
||||||
|
}
|
||||||
|
|
||||||
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
|
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
|
||||||
}
|
}
|
||||||
@@ -1139,6 +1141,17 @@ bool MusicWheel::Select() // return true of a playable item was chosen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( m_WheelState == STATE_RANDOM_SPINNING )
|
||||||
|
{
|
||||||
|
m_fPositionOffsetFromSelection = max(m_fPositionOffsetFromSelection, 0.3f);
|
||||||
|
m_WheelState = STATE_LOCKED;
|
||||||
|
m_Moving = 0;
|
||||||
|
m_soundStart.Play();
|
||||||
|
m_fLockedWheelVelocity = 0;
|
||||||
|
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch( m_CurWheelItemData[m_iSelection]->m_WheelItemType )
|
switch( m_CurWheelItemData[m_iSelection]->m_WheelItemType )
|
||||||
{
|
{
|
||||||
case TYPE_SECTION:
|
case TYPE_SECTION:
|
||||||
@@ -1175,42 +1188,7 @@ bool MusicWheel::Select() // return true of a playable item was chosen
|
|||||||
StartRoulette();
|
StartRoulette();
|
||||||
return false;
|
return false;
|
||||||
case TYPE_RANDOM:
|
case TYPE_RANDOM:
|
||||||
{
|
StartRandom();
|
||||||
const RANDOM_SPINS = 5;
|
|
||||||
|
|
||||||
/* Grab all of the currently-visible data. */
|
|
||||||
vector<WheelItemData *> &newData = m_CurWheelItemData;
|
|
||||||
newData.clear();
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Add RANDOM_SPINS * 2 worth of random items. */
|
|
||||||
int total = int(m_WheelItemDatas[SORT_ROULETTE].size());
|
|
||||||
for(i = 0; i < total; ++i)
|
|
||||||
swap(m_WheelItemDatas[SORT_ROULETTE][i], m_WheelItemDatas[SORT_ROULETTE][rand() % total]);
|
|
||||||
|
|
||||||
for(i = 0; i < RANDOM_SPINS * 2; ++i)
|
|
||||||
newData.push_back( &m_WheelItemDatas[SORT_ROULETTE][i] );
|
|
||||||
|
|
||||||
/* The cursor is on m_WheelItemDisplays[NUM_WHEEL_ITEMS_TO_DRAW/2].
|
|
||||||
* Fill from 0 to NUM_WHEEL_ITEMS_TO_DRAW, so all of the items
|
|
||||||
* that were on the screen stay there. However, skip some from
|
|
||||||
* the beginning to make sure we don't actually *land* on one. */
|
|
||||||
int fillstart = max(NUM_WHEEL_ITEMS_TO_DRAW/2 - RANDOM_SPINS + 1, 0);
|
|
||||||
|
|
||||||
for( i=fillstart; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
|
|
||||||
newData.push_back(m_WheelItemDisplays[i].data);
|
|
||||||
|
|
||||||
m_iSelection = newData.size() - NUM_WHEEL_ITEMS_TO_DRAW/2 - 1;
|
|
||||||
|
|
||||||
m_Moving = -1;
|
|
||||||
m_TimeBeforeMovingBegins = 0;
|
|
||||||
m_SpinSpeed = 1.0f/ROULETTE_SWITCH_SECONDS;
|
|
||||||
m_iSwitchesLeftInSpinDown = RANDOM_SPINS;
|
|
||||||
m_WheelState = STATE_RANDOM_SPINNING;
|
|
||||||
RebuildWheelItemDisplays();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case TYPE_SONG:
|
case TYPE_SONG:
|
||||||
@@ -1229,6 +1207,23 @@ void MusicWheel::StartRoulette()
|
|||||||
SetOpenGroup("", SongSortOrder(SORT_ROULETTE));
|
SetOpenGroup("", SongSortOrder(SORT_ROULETTE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MusicWheel::StartRandom()
|
||||||
|
{
|
||||||
|
/* Shuffle the roulette wheel. */
|
||||||
|
unsigned total = m_WheelItemDatas[SORT_ROULETTE].size();
|
||||||
|
for(unsigned i = 0; i < total; ++i)
|
||||||
|
swap(m_WheelItemDatas[SORT_ROULETTE][i], m_WheelItemDatas[SORT_ROULETTE][rand() % total]);
|
||||||
|
|
||||||
|
SetOpenGroup("", SongSortOrder(SORT_ROULETTE));
|
||||||
|
|
||||||
|
m_Moving = -1;
|
||||||
|
m_TimeBeforeMovingBegins = 0;
|
||||||
|
m_SpinSpeed = 1.0f/ROULETTE_SWITCH_SECONDS;
|
||||||
|
m_SpinSpeed *= 2.0f; /* faster! */
|
||||||
|
m_WheelState = STATE_RANDOM_SPINNING;
|
||||||
|
RebuildWheelItemDisplays();
|
||||||
|
}
|
||||||
|
|
||||||
void MusicWheel::SetOpenGroup(CString group, SongSortOrder so)
|
void MusicWheel::SetOpenGroup(CString group, SongSortOrder so)
|
||||||
{
|
{
|
||||||
if(so == NUM_SORT_ORDERS)
|
if(so == NUM_SORT_ORDERS)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "ScoreDisplayNormal.h"
|
#include "ScoreDisplayNormal.h"
|
||||||
#include "ScrollBar.h"
|
#include "ScrollBar.h"
|
||||||
#include "Course.h"
|
#include "Course.h"
|
||||||
|
#include "RageTimer.h"
|
||||||
|
|
||||||
|
|
||||||
const int NUM_WHEEL_ITEMS_TO_DRAW = 13;
|
const int NUM_WHEEL_ITEMS_TO_DRAW = 13;
|
||||||
@@ -105,6 +106,7 @@ public:
|
|||||||
bool PrevSort();
|
bool PrevSort();
|
||||||
bool NextSort();
|
bool NextSort();
|
||||||
void StartRoulette();
|
void StartRoulette();
|
||||||
|
void StartRandom();
|
||||||
bool IsRouletting() const;
|
bool IsRouletting() const;
|
||||||
/* Return true if we're moving fast automatically. */
|
/* Return true if we're moving fast automatically. */
|
||||||
int IsMoving() const;
|
int IsMoving() const;
|
||||||
@@ -147,6 +149,7 @@ protected:
|
|||||||
float m_fLockedWheelVelocity;
|
float m_fLockedWheelVelocity;
|
||||||
/* 0 = none; -1 or 1 = up/down */
|
/* 0 = none; -1 or 1 = up/down */
|
||||||
int m_Moving;
|
int m_Moving;
|
||||||
|
RageTimer m_MovingSoundTimer;
|
||||||
float m_TimeBeforeMovingBegins;
|
float m_TimeBeforeMovingBegins;
|
||||||
float m_SpinSpeed;
|
float m_SpinSpeed;
|
||||||
enum WheelState {
|
enum WheelState {
|
||||||
|
|||||||
Reference in New Issue
Block a user