ScreenRallyRace.cpp

Go to the documentation of this file.
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  * Copyright (c) 2007, Charles Lohr
00076  * All rights reserved.
00077  *
00078  * Redistribution and use in source and binary forms, with or
00079  * without modification, are permitted provided that the following
00080  * conditions are met:
00081  *  -   Redistributions of source code must retain the above
00082  *      copyright notice, this list of conditions and the following disclaimer.
00083  *  -   Redistributions in binary form must reproduce the above copyright
00084  *      notice, this list of conditions and the following disclaimer in
00085  *      the documentation and/or other materials provided with the distribution.
00086  *  -   Neither the name of the Mercury Engine nor the names of its
00087  *      contributors may be used to endorse or promote products derived from
00088  *      this software without specific prior written permission.
00089  *
00090  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00091  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00092  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00093  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00094  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00095  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00096  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00097  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00098  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00099  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00100  */

Hosted by SourceForge.net Logo