00001 #include "global.h"
00002 #include "ScreenJunq.h"
00003 #include "MercuryScreenManager.h"
00004 #include "MercuryInput.h"
00005 #include "MercuryLog.h"
00006 #include "MercuryTheme.h"
00007 #include "MercuryCommands.h"
00008 #include "MercuryDisplay.h"
00009 #include "MercuryTheme.h"
00010
00011 extern MercuryTimer gameTimer;
00012
00013 KeyMappingWithCode( button_a, "0-97" );
00014 KeyMappingWithCode( button_space, "0-32" );
00015 KeyMappingWithCode( button_p, "0-121" );
00016
00017 #include "MercuryObjectFactory.h"
00018 REGISTER_SCREEN_CLASS( ScreenJunq )
00019
00020 #define MC_INPUTMAPPED 1 //convention: MESSAGE CODE
00021 #define MC_INPUTUNMAPPED 2
00022
00023 ScreenJunq::~ScreenJunq()
00024 {
00025 DISPLAY->RemoveLight(&m_light);
00026 for(int i=0; i<64; i++)
00027 {
00028 SAFE_DELETE(m_Jsphere[i]);
00029 }
00030 }
00031
00032 void ScreenJunq::Init()
00033 {
00034 MercuryScreen::Init();
00035
00036 for(int i=0; i<64; i++)
00037 {
00038 MercuryLoadableModel* m = new MercuryLoadableModel;
00039 m->SetName( ssprintf( "Ksphere%d", i ) );
00040 m->Init();
00041 m->Load(GET_MODEL_BY_NAME( "Jsphere" ));
00042 this->AddObject( m );
00043 m_Jsphere.push_back( m );
00044 m->MoveZ( -600);
00045 m->MoveX( (float)((i / 8) * 40 - 140) );
00046 m->MoveY( (float)((i % 8) * 40 - 140));
00047 }
00048
00049 m_BPM = THEME.GetMetricI( m_name, "BPM" );
00050 m_In = ( ( 1.0f / ( (float)m_BPM / 60.0f ) ) * ( 1.0f/3.0f ) );
00051 m_Out = ( m_In * 2 );
00052 m_Beatctr = m_Peak = m_Measure =0;
00053 m_Type = THEME.GetMetricI( m_name, "BeatType" );
00054 m_Flow = THEME.GetMetricI( m_name, "BeatFlow" );
00055
00056 if(m_Flow == 0)
00057 {
00058 Tweening.AddCommand( ssprintf( THEME.GetMetricS( m_name, "BeatTweenSm" ), (m_In), (m_Out) ), MercuryTweenState::GLOBAL, "BeatTween" );
00059 }else{
00060 Tweening.AddCommand( ssprintf( THEME.GetMetricS( m_name, "BeatTweenSm" ), (m_In * 3), (m_Out * 3) ), MercuryTweenState::GLOBAL, "BeatTween" );
00061
00062 }
00063
00064 m_iDirection = 0;
00065 m_Move=1;
00066 time = real = 0;
00067
00068
00069 m_light.Init();
00070 m_light.SetY(100);
00071 m_light.SetX(-100);
00072 m_light.SetZ(110);
00073 m_light.SetAttenuation(0.001f, Attenuation::LINEAR);
00074
00075 DISPLAY->AddLight(&m_light);
00076
00077 this->RegisterMessage( MC_INPUTMAPPED, "mappedinput" );
00078 }
00079
00080 void ScreenJunq::Message( int Message, PStack & data, const MString & name )
00081 {
00082 switch ( Message )
00083 {
00084 case MC_INPUTMAPPED:
00085 {
00086 InputMessageStruct c(data);
00087 if ( (c.code == button_space ) && c.type == IET_RELEASE )
00088 {
00089 m_Measure=16;
00090 }
00091
00092
00093
00094
00095
00096
00097
00098 break;
00099 }
00100 };
00101 }
00102
00103 void ScreenJunq::Update( const float dTime )
00104 {
00105 time += dTime;
00106 if( time >= real )
00107 {
00108 m_Beatctr++; m_Measure++;
00109 PStack myStack;
00110 int i, j;
00111 switch (m_Type)
00112 {
00113 case 0:
00114 for(i=0; i<8; i++)
00115 {
00116 if(i<4)
00117 {
00118 for(j=0; j<4; j++)
00119 {
00120 m_Jsphere[(i*8)+j+(m_Move*4)]->Tweening.StopTweening();
00121 m_Jsphere[(i*8)+j+(m_Move*4)]->Tweening.ExecuteCommand( "BeatTween", myStack );
00122 }
00123 }else{
00124 for(j=0; j<4; j++)
00125 {
00126 m_Jsphere[(i*8)+j+((1-m_Move)*4)]->Tweening.StopTweening();
00127 m_Jsphere[(i*8)+j+((1-m_Move)*4)]->Tweening.ExecuteCommand( "BeatTween", myStack );
00128 }
00129 }
00130 }
00131 m_Move=1-m_Move;
00132 break;
00133 case 1:
00134 for(i=0; i<8; i++)
00135 {
00136 for(j=0; j<8; j++)
00137 {
00138 if( (i==m_Move || j==m_Move) || (7-i==m_Move || 7-j==m_Move) )
00139 {
00140 m_Jsphere[(i*8)+j]->Tweening.StopTweening();
00141 m_Jsphere[(i*8)+j]->Tweening.ExecuteCommand( "BeatTween", myStack );
00142 }
00143 }
00144 }
00145 if(m_Move >= 3)
00146 {
00147 m_Move=0;
00148 }else{
00149 m_Move++;
00150 }
00151 break;
00152 case 2:
00153 for(i=0; i<8; i++)
00154 {
00155 for(j=0; j<7; j+=2)
00156 {
00157 m_Jsphere[(i*8)+j+m_Move]->Tweening.StopTweening();
00158 m_Jsphere[(i*8)+j+m_Move]->Tweening.ExecuteCommand( "BeatTween", myStack );
00159
00160 }
00161 if(m_Move==0)
00162 m_Move++;
00163 else
00164 m_Move--;
00165
00166 }
00167 if(m_Move==0)
00168 m_Move++;
00169 else
00170 m_Move--;
00171 break;
00172 case 3:
00173 for(i=0; i<8; i++)
00174 {
00175 for(j=0; j<8; j++)
00176 {
00177 if( (i==3-m_Move || j==3-m_Move) || (7-i==3-m_Move || 7-j==3-m_Move) )
00178 {
00179 m_Jsphere[(i*8)+j]->Tweening.StopTweening();
00180 m_Jsphere[(i*8)+j]->Tweening.ExecuteCommand( "BeatTween", myStack );
00181 }
00182 }
00183 }
00184 if(m_Move >= 3)
00185 {
00186 m_Move=0;
00187 }else{
00188 m_Move++;
00189 }
00190 break;
00191 }
00192 if(m_Measure>=16)
00193 {
00194 if(m_Type>=3)
00195 {
00196 m_Type=0;
00197 }else{
00198 m_Type++;
00199 }
00200 m_Measure=0;
00201 m_Move=0;
00202 }
00203
00204
00205
00206
00207
00208
00209
00210 real += (m_In * 3);
00211 }
00212
00213 MercuryScreen::Update( dTime );
00214 }
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241