SuperTuxKart
rubber_band.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2008-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (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 HEADER_RUBBER_BAND_HPP
20 #define HEADER_RUBBER_BAND_HPP
21 
22 #include "utils/no_copy.hpp"
23 #include "utils/vec3.hpp"
24 
25 #include <cinttypes>
26 #include <memory>
27 
28 namespace SP
29 {
30  class SPDynamicDrawCall;
31 }
32 
33 class AbstractKart;
34 class Plunger;
35 
40 class RubberBand : public NoCopy
41 {
42 public:
44 {
45  RB_TO_PLUNGER = 0,
47  RB_TO_TRACK
48 };
49 private:
56 
57  RubberBandTo m_attached_state;
58 
60  std::shared_ptr<SP::SPDynamicDrawCall> m_dy_dc;
61 
67 
68  void checkForHit(const Vec3 &k, const Vec3 &p);
69  void updatePosition();
70 
71 public:
72  RubberBand(Plunger *plunger, AbstractKart *kart);
73  ~RubberBand();
74  void reset();
75  void updateGraphics(float dt);
76  void update(int ticks);
77  void hit(AbstractKart *kart_hit, const Vec3 *track_xyz=NULL);
78  uint8_t get8BitState() const;
79  void set8BitState(uint8_t bit_state);
80  void remove();
81 }; // RubberBand
82 #endif
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
Definition: b3d_mesh_loader.hpp:18
Vec3 m_hit_position
If rubber band is attached to track, the coordinates.
Definition: rubber_band.hpp:51
AbstractKart * m_owner
The kart who shot this plunger.
Definition: rubber_band.hpp:55
RubberBandTo
Definition: rubber_band.hpp:43
Definition: plunger.hpp:38
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
std::shared_ptr< SP::SPDynamicDrawCall > m_dy_dc
The dynamic draw call of the rubber band.
Definition: rubber_band.hpp:60
Plunger * m_plunger
The plunger the rubber band is attached to.
Definition: rubber_band.hpp:53
Vec3 m_end_position
Stores the end of the rubber band (i.e.
Definition: rubber_band.hpp:66
AbstractKart * m_hit_kart
The kart a plunger might have hit.
Definition: rubber_band.hpp:63
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
Rubber band is attached to a kart hit.
Definition: rubber_band.hpp:46
This class is used together with the pluger to display a rubber band from the shooting kart to the pl...
Definition: rubber_band.hpp:40