1 /* $Id: Player.h,v 1.21 2003/07/16 16:11:14 nan Exp $ */ 2 3 // Copyright (C) 2000, 2001, 2002 $B?@Fn(B $B5H9((B(Kanna Yoshihiro) 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 2 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 #ifndef _Player_ 20 #define _Player_ 21 #include "PlayerView.h" 22 #include "PlayerView2D.h" 23 24 // m_playerType 25 #define PLAYER_PROTO 0 // Prototype player 26 #define PLAYER_PENATTACK 1 // Pen Attack 27 #define PLAYER_SHAKECUT 2 // Cut 28 #define PLAYER_PENDRIVE 3 // Pen Drive 29 30 31 // m_swingType 32 #define SWING_NORMAL 0 // 33 #define SWING_POKE 1 // push? 34 #define SWING_SMASH 2 // 35 #define SWING_DRIVE 3 // 36 #define SWING_CUT 4 // 37 #define SWING_BLOCK 5 // 38 39 40 class PlayerView; 41 class HitMark; 42 class Ball; 43 44 class Player { 45 friend class Howto; 46 friend class Opening; 47 friend class OpeningView; 48 public: 49 Player(); 50 Player( long side ); 51 Player( long playerType, long side, double x, double y, double z, 52 double vx, double vy, double vz,long status, long swing, 53 long swingType, bool swingSide, long afterSwing, long swingError, 54 double targetX, double targetY, double eyeX, double eyeY, 55 double eyeZ, long pow, double spin, double stamina, long statusMax ); 56 57 virtual ~Player(); 58 59 void operator=(Player&); 60 61 static Player* Create( long player, long side, long type ); 62 63 virtual bool Init(); 64 65 //virtual bool Reset( struct PlayerData *p ); 66 virtual bool Reset( Player *p ); 67 68 virtual bool Move( SDL_keysym *KeyHistory, long *MouseXHistory, 69 long *MouseYHistory, unsigned long *MouseBHistory, 70 int Histptr ); 71 72 virtual bool AddStatus( long diff ); 73 GetView()74 virtual View *GetView() { return m_View; }; 75 GetSide()76 virtual long GetSide() { return m_side; } GetPlayerType()77 virtual long GetPlayerType() { return m_playerType; } 78 GetX()79 virtual double GetX() { return m_x; } GetY()80 virtual double GetY() { return m_y; } GetZ()81 virtual double GetZ() { return m_z; } GetVX()82 virtual double GetVX() { return m_vx; } GetVY()83 virtual double GetVY() { return m_vy; } GetVZ()84 virtual double GetVZ() { return m_vz; } GetPower()85 virtual long GetPower() { return m_pow; } GetSpin()86 virtual double GetSpin() { return m_spin; } GetTargetX()87 virtual double GetTargetX() { return m_targetX; } GetTargetY()88 virtual double GetTargetY() { return m_targetY; } GetEyeX()89 virtual double GetEyeX() { return m_eyeX; } GetEyeY()90 virtual double GetEyeY() { return m_eyeY; } GetEyeZ()91 virtual double GetEyeZ() { return m_eyeZ; } GetLookAtX()92 virtual double GetLookAtX() { return m_lookAtX; } GetLookAtY()93 virtual double GetLookAtY() { return m_lookAtY; } GetLookAtZ()94 virtual double GetLookAtZ() { return m_lookAtZ; } GetStamina()95 virtual double GetStamina() { return m_stamina; } GetStatus()96 virtual long GetStatus() { return m_status; } GetSwing()97 virtual long GetSwing() { return m_swing; } GetSwingType()98 virtual long GetSwingType() { return m_swingType; } GetSwingSide()99 virtual bool GetSwingSide() { return m_swingSide; } GetSwingError()100 virtual long GetSwingError() { return m_swingError; } GetAfterSwing()101 virtual long GetAfterSwing() { return m_afterSwing; } 102 GetDragX()103 virtual long GetDragX() { return m_dragX; } GetDragY()104 virtual long GetDragY() { return m_dragY; } 105 106 virtual bool GetShoulder( double &x, double &y, double ° ); 107 virtual bool GetElbow( double °x, double& degy ); 108 virtual bool GetHand( double °x, double °y, double °z ); 109 110 // true -> forehand 111 // false -> backhand 112 virtual bool ForeOrBack(); 113 114 virtual bool Warp( double x, double y, double z, 115 double vx, double vy, double vz ); 116 virtual bool ExternalSwing( long pow, double spin, long swingType, long swing ); 117 118 virtual bool Warp( char *buf ); 119 virtual bool ExternalSwing( char *buf ); 120 121 virtual char * SendSwing( char *buf ); 122 virtual char * SendLocation( char *buf ); 123 virtual bool SendAll( int sd ); 124 125 virtual bool GetModifiedTarget( double &targetX, double &targetY ); 126 127 virtual void CalcLevel( Ball *ball, double &diff, double &level, double &maxVy ); 128 129 long StatusBorder(); 130 protected: 131 long m_playerType; // Player type 132 133 long m_side; // 1 --- ( y < 0 ) 134 // -1 --- ( y > 0 ) 135 136 double m_x; // player location 137 double m_y; 138 double m_z; 139 double m_vx; // player velocity 140 double m_vy; 141 double m_vz; 142 143 long m_status; // status gauge 144 long m_swing; // swing status 145 long m_swingType; // swing type 146 bool m_swingSide; // forehand or backhand 147 long m_afterSwing; // 148 long m_swingError; // Error when hitting 149 // 0 --- Perfect 150 // 1 --- Great 151 // 2 --- Good 152 // 3 --- Boo 153 // 4 --- Miss 154 double m_targetX; // location of target circle 155 double m_targetY; // location of target circle 156 157 double m_eyeX; // Viewpoint 158 double m_eyeY; 159 double m_eyeZ; 160 161 double m_lookAtX; 162 double m_lookAtY; 163 double m_lookAtZ; 164 165 long m_pow; // power 166 double m_spin; // topspin/backspin 167 168 double m_stamina; 169 170 long m_statusMax; // Max status value 171 172 long m_dragX; 173 long m_dragY; // Mouse drag 174 175 PlayerView* m_View; 176 177 double m_lastSendX; 178 double m_lastSendY; 179 double m_lastSendZ; 180 double m_lastSendVX; 181 double m_lastSendVY; 182 double m_lastSendVZ; 183 long m_lastSendCount; 184 185 virtual bool KeyCheck( SDL_keysym *KeyHistory, long *MouseXHistory, 186 long *MouseYHistory, unsigned long *MouseBHistory, 187 int Histptr ); 188 virtual bool Swing( long power ); 189 virtual bool StartSwing( long power ); 190 191 virtual bool HitBall(); 192 193 virtual bool SwingError(); 194 195 void UpdateLastSend(); 196 197 void AddError( double &vx, double &vy, double &vz ); 198 }; 199 200 #endif // _Player_ 201