src/tron/gCamera.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #include "tMemManager.h"
00029 #include "gCycle.h"
00030 #include "gCamera.h"
00031 #include "gGame.h"
00032 #include "ePlayer.h"
00033 #include "rFont.h"
00034 #include "eSoundMixer.h"
00035 
00036 void gCamera::MyInit(){
00037     if (mode == CAMERA_SMART)
00038         if (sg_currentSettings->finishType==gFINISH_EXPRESS && sn_GetNetState() != nCLIENT )
00039             pos=CenterPos()+dir.Turn(eCoord(-2,-10)) ;
00040 
00041     lastCenter=Center();
00042 }
00043 
00044 gCamera::gCamera(eGrid *grid, rViewport *view,ePlayerNetID *p,ePlayer *lp,eCamMode m)
00045         :eCamera(grid, view,p,lp,m), lastCenter(NULL){
00046     MyInit();
00047 }
00048 
00049 
00050 gCamera::~gCamera(){
00051     int x;
00052     x =0;
00053 }
00054 
00055 eCoord gCamera::CenterCycleDir(){
00056     gCycle *c = dynamic_cast<gCycle *>( Center());
00057     if (c)
00058         return c->CamDir();
00059     else
00060         return CenterDir();
00061 }
00062 
00063 REAL gCamera::SpeedMultiplier() const
00064 {
00065     return gCycle::SpeedMultiplier();
00066 }
00067 
00068 void gCamera::Timestep(REAL ts){
00069     eCamera::Timestep(ts);
00070     if (Center()!=lastCenter){
00071         if (!netPlayer || !netPlayer->Object() ||
00072                 netPlayer->Object()!=center){
00073             if (dynamic_cast<gCycle *>(Center())){
00074                 eNetGameObject *x=dynamic_cast<eNetGameObject *>(Center());
00075                 if (x){
00076                     const ePlayerNetID *p=x->Player();
00077                     if (p==NULL)
00078                         con << tOutput("$camera_watching_ai");
00079                     else{
00080                         tOutput o;
00081                         o.SetTemplateParameter(1, p->GetName());
00082                         o << "$camera_watching_player";
00083                         con << o;
00084                     }
00085                 }
00086             }
00087             lastCenter=Center();
00088 
00089             eSoundMixer* mixer = eSoundMixer::GetMixer();
00090             mixer->SetMicrophoneOwner(Center());
00091         }
00092     }
00093 }
00094 
00095 
00096 
00097 
00098 
00099 

Generated on Sat Mar 15 22:56:06 2008 for Armagetron Advanced by  doxygen 1.5.4