00001 #include "ScreenRallyRace.h"
00002 #include "RaceCar.h"
00003 #include "MercuryTheme.h"
00004 #include "MercuryInput.h"
00005
00006 REGISTER_SCREEN_CLASS( ScreenRallyRace );
00007
00008 KeyMappingWithCode( button_a, "0-97" );
00009 KeyMappingWithCode( button_b, "0-98" );
00010 KeyMappingWithCode( button_s, "0-115" );
00011 KeyMappingWithCode( button_d, "0-100" );
00012 KeyMappingWithCode( button_w, "0-119" );
00013
00014 ScreenRallyRace::~ScreenRallyRace()
00015 {
00016 m_pCamera = NULL;
00017 }
00018
00019 void ScreenRallyRace::Init()
00020 {
00021 m_pCamera = &m_fCamera;
00022 m_fCamera.Init();
00023 m_fCamera.SetPosition( MercuryPoint( 200,0, 200 ) );
00024 m_fCamera.SetTarget( MercuryPoint( 0,0,0 ) );
00025 m_fCamera.SetUp( MercuryPoint ( 0,0,1 ) );
00026 AddPerspObject( m_pCamera, false );
00027
00028 m_pINI.Open( GET_FILE_BY_NAME( "IniFile" ) );
00029 m_pWorld.Init();
00030 m_pWorld.LoadFromINI( m_pINI, THEME.GetMetricS( m_name, "WorldName" ) );
00031 AddPerspObject( &m_pWorld );
00032
00033 ScreenOutdoors::Init();
00034
00035 MercuryObject * o = OBJECTREGISTER.GetObjectFromName( "Track1RaceCar" );
00036 if( o->IsTypeOf( "RaceCar" ) )
00037 {
00038 RaceCar * r = (RaceCar*)o;
00039 r->ChangeSteer( 0 );
00040 }
00041 }
00042
00043 void ScreenRallyRace::Update( const float dTime )
00044 {
00045 MercuryObject * o = OBJECTREGISTER.GetObjectFromName( "Track1RaceCar" );
00046 if( o->IsTypeOf( "RaceCar" ) )
00047 {
00048 RaceCar * r = (RaceCar*)o;
00049 r->SetBreak( INPUTMAN->IsButtonDown( button_b ) );
00050
00051 r->ChangeSteer( 0 );
00052 if( INPUTMAN->IsButtonDown( button_a ) )
00053 r->ChangeSteer( .1 );
00054
00055 if( INPUTMAN->IsButtonDown( button_d ) )
00056 r->ChangeSteer( -.1 );
00057
00058 r->ChangeTopSpeed( 200 );
00059 m_fCamera.SetTarget( o->GetPosition() );
00060 m_fCamera.SetPosition( o->GetPosition() + MercuryPoint( 100, 0, 100 ) );
00061
00062 }
00063 ScreenOutdoors::Update( dTime );
00064
00065 m_fCamera.SetTarget( o->GetPosition() );
00066 m_fCamera.SetPosition( o->GetPosition() + MercuryPoint( 100, 0, 100 ) );
00067 }
00068
00069 void ScreenRallyRace::Message( int Message, PStack & data, const MString & name )
00070 {
00071 ScreenOutdoors::Message( Message, data, name );
00072 }
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100