1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
/* $Id: Training.cpp,v 1.11 2003/07/16 15:55:24 nan Exp $ */
// Copyright (C) 2000, 2001, 2002 神南 吉宏(Kanna Yoshihiro)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "ttinc.h"
#include "Training.h"
#include "TrainingView.h"
#include "BaseView.h"
#include "Player.h"
#include "Ball.h"
#include "Event.h"
extern Ball theBall;
extern long mode;
Training::Training() {
m_View = NULL;
m_trainingCount = 0;
m_trainingMax = 0;
}
Training::~Training() {
if ( m_View ){
BaseView::TheView()->RemoveView( m_View );
delete m_View;
}
}
bool
Training::Init() {
m_View = (TrainingView *)View::CreateView( VIEW_TRAINING );
m_View->Init( this );
BaseView::TheView()->AddView( m_View );
return true;
}
void
Training::Create( long player, long com ) {
Control::ClearControl();
m_theControl = new Training();
m_theControl->Init();
m_thePlayer = Player::Create( player, 1, 2 );
m_comPlayer = Player::Create( com, -1, 3 );
m_thePlayer->Init();
m_comPlayer->Init();
// Move it to view?
SDL_ShowCursor(0);
SDL_WM_GrabInput( SDL_GRAB_ON );
}
bool
Training::Move( SDL_keysym *KeyHistory, long *MouseXHistory,
long *MouseYHistory, unsigned long *MouseBHistory,
int Histptr ) {
bool reDraw = false;
long ballStatus = theBall.GetStatus();
if ( KeyHistory[Histptr].unicode == 'Q' ) {
mode = MODE_TITLE;
return true;
}
theBall.Move();
reDraw |= m_thePlayer->Move( KeyHistory, MouseXHistory,
MouseYHistory, MouseBHistory, Histptr );
reDraw |= m_comPlayer->Move( NULL, NULL, NULL, NULL, 0 );
if ( ballStatus != theBall.GetStatus() ) {
if ( theBall.GetStatus() == 8 ) {
if ( m_trainingCount > m_trainingMax )
m_trainingMax = m_trainingCount;
m_trainingCount = 0;
}
}
return reDraw;
}
bool
Training::LookAt( double &srcX, double &srcY, double &srcZ,
double &destX, double &destY, double &destZ ) {
if (m_thePlayer) {
srcX = m_thePlayer->GetX() + m_thePlayer->GetEyeX();
srcY = m_thePlayer->GetY() + m_thePlayer->GetEyeY();
srcZ = m_thePlayer->GetZ() + m_thePlayer->GetEyeZ();
destX = m_thePlayer->GetLookAtX();
destY = m_thePlayer->GetLookAtY();
destZ = m_thePlayer->GetLookAtZ();
}
return true;
}
void
Training::AddTrainingCount() {
m_trainingCount++;
}
|