SuperTuxKart
cake.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2007-2015 Joerg Henrichs
4 //
5 // Physics improvements and linear intersection algorithm by
6 // Copyright (C) 2009-2015 David Mikos.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 3
11 // of the License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22 #ifndef HEADER_CAKE_HPP
23 #define HEADER_CAKE_HPP
24 
25 namespace irr
26 {
27  namespace scene { class IMesh; }
28 }
29 #include <irrString.h>
30 
31 #include "items/flyable.hpp"
32 
33 class XMLNode;
34 
38 class Cake : public Flyable
39 {
40 private:
43  static float m_gravity;
44 
45  btVector3 m_initial_velocity;
46 
49 
50 public:
51  Cake (AbstractKart *kart);
52  static void init (const XMLNode &node, scene::IMesh *cake_model);
53  virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL) OVERRIDE;
54  // ------------------------------------------------------------------------
55  virtual void hitTrack () OVERRIDE
56  {
57  if (!m_has_server_state)
58  return;
59  hit(NULL);
60  }
61  // ------------------------------------------------------------------------
65  virtual const btVector3 &getVelocity() const OVERRIDE
66  { return m_initial_velocity; }
67  // ------------------------------------------------------------------------
73  virtual void setVelocity(const btVector3& v) OVERRIDE
74  { m_initial_velocity = v; }
75  // ------------------------------------------------------------------------
76  virtual void onFireFlyable() OVERRIDE;
77 }; // Cake
78 
79 #endif
virtual const btVector3 & getVelocity() const OVERRIDE
Kinematic objects are not allowed to have a velocity (assertion in bullet), so we have to do our own ...
Definition: cake.hpp:65
virtual bool hit(AbstractKart *kart, PhysicalObject *obj=NULL) OVERRIDE
Callback from the physics in case that a kart or physical object is hit.
Definition: cake.cpp:64
static void init(const XMLNode &node, scene::IMesh *cake_model)
Initialises the object from an entry in the powerup.xml file.
Definition: cake.cpp:44
Definition: physical_object.hpp:40
virtual void onFireFlyable() OVERRIDE
Call when the item is (re-)fired (during rewind if needed) by projectile_manager.
Definition: cake.cpp:81
Moveable * m_target
Which kart is targeted by this projectile (NULL if none).
Definition: cake.hpp:48
Definition: cake.hpp:38
virtual void setVelocity(const btVector3 &v) OVERRIDE
Kinematic objects are not allowed to have a velocity (assertion in bullet), so we have to do our own ...
Definition: cake.hpp:73
utility class used to parse XML files
Definition: xml_node.hpp:47
Definition: moveable.hpp:44
Definition: flyable.hpp:47
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
virtual void hitTrack() OVERRIDE
Called when this flyable hits the track.
Definition: cake.hpp:55
static float m_st_max_distance_squared
Maximum distance for a missile to be attracted.
Definition: cake.hpp:42