Back to index

supertuxkart  0.5+dfsg1
flyable.hpp
Go to the documentation of this file.
00001 //  $Id: flyable.hpp 1284 2007-11-08 12:31:54Z hikerstk $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2007 Joerg Henrichs
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_FLYABLE_H
00021 #define HEADER_FLYABLE_H
00022 
00023 #include "moveable.hpp"
00024 #include "moving_physics.hpp"
00025 #include "kart.hpp"
00026 #include "terrain_info.hpp"
00027 
00028 class Flyable : public Moveable, public TerrainInfo
00029 {
00030     sgCoord           m_last_pos;
00031     bool              m_has_hit_something;
00032     int               m_last_radar_beep;
00033     bool              m_exploded;
00034 
00035 protected:
00036     const Kart*       m_owner;              // the kart which released this flyable
00037     btCollisionShape *m_shape;
00038     float             m_max_height;
00039     float             m_min_height;
00040     float             m_average_height;     // average of m_{min,ax}_height
00041     float             m_force_updown;
00042     float             m_speed;
00043     float             m_mass;
00044     btVector3         m_extend;
00045     // The flyable class stores the values for each flyable type, e.g. 
00046     // speed, min_height, max_height. These variables must be static,
00047     // so we need arrays of these variables to have different values
00048     // for sparks, missiles, ...
00049     static float      m_st_speed[COLLECT_MAX];         // Speed of the projectile
00050     static ssgEntity* m_st_model[COLLECT_MAX];         // 3d model
00051     static float      m_st_min_height[COLLECT_MAX];    // min height above track
00052     static float      m_st_max_height[COLLECT_MAX];    // max height above track
00053     static float      m_st_force_updown[COLLECT_MAX];  // force pushing up/down 
00054     static btVector3  m_st_extend[COLLECT_MAX];        // size of the model
00055 
00056     void              getClosestKart(const Kart **minKart, float *minDist, 
00057                                      btVector3 *minDelta) const;
00058     void              createPhysics(float y_offset, 
00059                                     const btVector3 velocity,
00060                                     btCollisionShape *shape);
00061 public:
00062 
00063                  Flyable     (Kart* kart, CollectableType type);
00064     virtual     ~Flyable     ();
00065     static void  init        (const lisp::Lisp* lisp, ssgEntity *model, 
00066                               CollectableType type);
00067     virtual void update      (float);
00068 
00069     void placeModel          ();
00070     virtual void hitTrack    () {};
00071     void         explode     (Kart* kart, MovingPhysics* moving_physics=NULL);
00072     bool         hasHit      ()               { return m_has_hit_something; }
00073     void         reset       () { Moveable::reset();
00074                                   sgCopyCoord(&m_last_pos,&m_reset_pos );   }
00075 };   // Flyable
00076 
00077 #endif