00001 #include "MercuryScreen.h"
00002 #include "MercuryInput.h"
00003 #include "MercuryINI.h"
00004 #include "MercurySoundObject.h"
00005 #include "MercurySoundManager.h"
00006 #include "MercuryTheme.h"
00007
00008 class ScreenGameForBlind : public MercuryScreen
00009 {
00010 public:
00011 ScreenGameForBlind() : MercuryScreen() { }
00012 ScreenGameForBlind( const MString & name ) : MercuryScreen( name ) { m_name = name; }
00013 virtual ~ScreenGameForBlind();
00014
00015 virtual void Init();
00016 virtual void Update( const float dTime );
00017 virtual void Message( int Message, PStack & data, const MString & name );
00018 CLASS_RTTI( ScreenGameForBlind, MercuryScreen );
00019 private:
00020 MercurySprite sprGround;
00021 MercurySprite sprPerson;
00022 MercurySprite sprTarget;
00023
00024 MercurySoundObject * sndTarget;
00025
00026 MercuryPoint pPerson;
00027 MercuryPoint pTarget;
00028
00029 float fRotation;
00030 int iLastMouseX;
00031 };
00032
00033 #include "MercuryObjectFactory.h"
00034 REGISTER_SCREEN_CLASS( ScreenGameForBlind )
00035
00036 KeyMappingWithCode( button_a, "0-97" );
00037 KeyMappingWithCode( button_s, "0-115" );
00038 KeyMappingWithCode( button_d, "0-100" );
00039 KeyMappingWithCode( button_w, "0-119" );
00040
00041 ScreenGameForBlind::~ScreenGameForBlind()
00042 {
00043
00044 }
00045
00046 void ScreenGameForBlind::Init()
00047 {
00048 MercuryScreen::Init();
00049
00050 sprGround.SetName( "Ground" );
00051 sprGround.Init();
00052 sprGround.LoadImage( GET_GRAPHIC_BY_NAME( "Ground" ) );
00053 AddOrthoObject( &sprGround );
00054
00055 sprPerson.SetName( "Person" );
00056 sprPerson.Init();
00057 sprPerson.LoadImage( GET_GRAPHIC_BY_NAME( "Person" ) );
00058 AddOrthoObject( &sprPerson );
00059
00060 sprTarget.SetName( "Target" );
00061 sprTarget.Init();
00062 sprTarget.LoadImage( GET_GRAPHIC_BY_NAME( "Target" ) );
00063 AddOrthoObject( &sprTarget );
00064 pTarget = MercuryPoint( 100,100,0 );
00065
00066 sndTarget = SOUNDMAN->Load(THEME.GetMetricS(GetName(), "Wav"));
00067 sndTarget->SetLoop(true);
00068 sndTarget->Play();
00069 sndTarget->SetDoppler( 0.4f );
00070 AddObject( sndTarget, true );
00071
00072 fRotation = 0;
00073 int x,y;
00074 INPUTMAN->GetCursorPosition( x, y );
00075 iLastMouseX = x;
00076
00077 SetPosition( MercuryPoint( 320, 240, 0 ) );
00078 }
00079
00080 void ScreenGameForBlind::Update( const float dTime )
00081 {
00082 int x = 0,y = 0;
00083
00084 if ( INPUTMAN->IsButtonDown( button_a ) ) x = -1;
00085 if ( INPUTMAN->IsButtonDown( button_s ) ) y = 1;
00086 if ( INPUTMAN->IsButtonDown( button_d ) ) x = 1;
00087 if ( INPUTMAN->IsButtonDown( button_w ) ) y = -1;
00088
00089 float AngleToGo=fRotation*DEGRAD;
00090
00091 pPerson += Rotate2DPoint( AngleToGo, MercuryPoint( float(x)*dTime*30, float(y)*dTime*30, 0 ) );
00092
00093 if( pPerson.x < -250 )
00094 pPerson.x = -250;
00095 if( pPerson.y < -250 )
00096 pPerson.y = -250;
00097 if( pPerson.x > 250 )
00098 pPerson.x = 250;
00099 if( pPerson.y > 250 )
00100 pPerson.y = 250;
00101
00102 INPUTMAN->GetCursorPosition( x, y );
00103 y = x - iLastMouseX;
00104 iLastMouseX = x;
00105 fRotation+=float(y)/4.0f;
00106
00107 SetRot( MercuryPoint( 0, 0, fRotation ) );
00108 sprPerson.SetRot( MercuryPoint( 0, 0, -fRotation ) );
00109
00110 sprGround.SetPosition( -1 * pPerson );
00111 sprTarget.SetPosition( -1 * pPerson + pTarget );
00112
00113 sndTarget->SetPosition( Rotate2DPoint(-AngleToGo,pTarget-pPerson)/50 - MercuryPoint( 320, 240, 0 ) );
00114
00115 MercuryScreen::Update( dTime );
00116 }
00117
00118 void ScreenGameForBlind::Message( int Message, PStack &data, const MString &name )
00119 {
00120 MercuryScreen::Message( Message, data, name );
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150