Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ship.h

Go to the documentation of this file.
00001 
00002 /*
00003     TSGL - Teddy Space Game Library
00004     Copyright (C) 2002 Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: Ship.h,v 1.1 2002/01/08 20:47:05 tksuoran Exp $
00022 */
00023 
00024 
00025 #ifndef TEDDY__SPACE_GAME__SHIP_H
00026 #define TEDDY__SPACE_GAME__SHIP_H
00027 
00028 
00029 #include "Teddy/Maths/Vector.h"
00030 #include "Teddy/MixIn/Named.h"
00031 #include "Teddy/SpaceGame/SimulatedInstance.h"
00032 using namespace Teddy::Models;
00033 
00034 
00035 namespace Teddy     {
00036 namespace SpaceGame {
00037 
00038 
00039 class Root;
00040 class ShipType;
00041 
00042 
00047 class Ship : public SimulatedInstance {
00048 public:
00049     Ship( char *name, ShipType *ship_type, Root *root );
00050 
00051     ShipType      *getShipType      ();
00052     void           setTarget        ( ModelInstance *mi, Vector offset = Vector(0,0,0) );
00053     ModelInstance *getTarget        ();
00054     void           setTargetPosition();
00055     float          getPitch         () const;
00056     float          getRoll          () const;
00057     float          getSpeed         () const;
00058 
00059     //  Simulation update
00060     virtual void   tick             ();
00061 
00062     //  ShipControls
00063     void           controlPitchUp   ( bool apply );
00064     void           controlPitchDown ( bool apply );
00065     void           controlRollLeft  ( bool apply );
00066     void           controlRollRight ( bool apply );
00067     void           controlMoreSpeed ( bool apply );
00068     void           controlLessSpeed ( bool apply );
00069     void           controlStop      ( bool apply );
00070     void           controlFireWeapon( bool apply );
00071 
00072     void           stopSpeed        ();
00073     void           stopPitch        ();
00074     void           stopRoll         ();
00075 
00076     //  Temporary
00077     void           collide          ();
00078 
00079     //  Low level AI
00080     float          getBrakeDistance () const;
00081     float          getTargetDistance() const;
00082     float          getPitchDistance (){ return pitch_distance; };
00083     float          getRollDistance  (){ return roll_distance;  };
00084 
00085     //  Medium level AI
00086     void           trackTarget      ();
00087 
00088     //  Master level
00089     virtual void   applyControls    ( float age );
00090 
00091 protected:
00092     Root           *root;                 
00093     ShipType       *ship_type;
00094     ModelInstance  *target;               
00095     Vector          target_offset;        
00096     float           prev_bullet_time;
00097 
00098     bool            control_pitch_up;     
00099     bool            control_pitch_down;   
00100     bool            control_roll_left;    
00101     bool            control_roll_right;   
00102     bool            control_more_speed;   
00103     bool            control_less_speed;   
00104     bool            control_stop;         
00105     bool            control_fire_weapon;  
00106     bool            active_pitch;         
00107     bool            active_roll;          
00108 
00109     float           pitch_delta;
00110     float           roll_delta;
00111     float           pitch;             
00112     float           roll;              
00113     float           speed;             
00114     float           accel;             
00115     float           pitch_distance;    
00116     float           roll_distance;     
00117 };
00118 
00119 
00120 };  //  namespace SpaceGame
00121 };  //  namespace Teddy
00122 
00123 
00124 #endif  //  TEDDY__SPACE_GAME__SHIP_H
00125