SuperTuxKart
Loading...
Searching...
No Matches
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
28namespace SP
29{
30 class SPDynamicDrawCall;
31}
32
33namespace irr
34{
35 namespace scene
36 {
37 class IMeshSceneNode;
38 }
39}
40
41class AbstractKart;
42class Plunger;
43
48class RubberBand : public NoCopy
49{
50public:
52{
56};
57private:
64
65 RubberBandTo m_attached_state;
66
68 std::shared_ptr<SP::SPDynamicDrawCall> m_dy_dc;
69
70 irr::scene::IMeshSceneNode* m_node;
71
77
78 void checkForHit(const Vec3 &k, const Vec3 &p);
79 void updatePosition();
80
81public:
82 RubberBand(Plunger *plunger, AbstractKart *kart);
84 void reset();
85 void updateGraphics(float dt);
86 void update(int ticks);
87 void hit(AbstractKart *kart_hit, const Vec3 *track_xyz=NULL);
88 uint8_t get8BitState() const;
89 void set8BitState(uint8_t bit_state);
90 void remove();
91}; // RubberBand
92#endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: plunger.hpp:39
This class is used together with the pluger to display a rubber band from the shooting kart to the pl...
Definition: rubber_band.hpp:49
std::shared_ptr< SP::SPDynamicDrawCall > m_dy_dc
The dynamic draw call of the rubber band.
Definition: rubber_band.hpp:68
Vec3 m_hit_position
If rubber band is attached to track, the coordinates.
Definition: rubber_band.hpp:59
void updatePosition()
Updates the position of the rubber band.
Definition: rubber_band.cpp:144
void checkForHit(const Vec3 &k, const Vec3 &p)
Uses a raycast to see if anything has hit the rubber band.
Definition: rubber_band.cpp:314
Plunger * m_plunger
The plunger the rubber band is attached to.
Definition: rubber_band.hpp:61
void update(int ticks)
Updates the rubber band.
Definition: rubber_band.cpp:251
AbstractKart * m_owner
The kart who shot this plunger.
Definition: rubber_band.hpp:63
void hit(AbstractKart *kart_hit, const Vec3 *track_xyz=NULL)
The plunger hit a kart or the track.
Definition: rubber_band.cpp:352
Vec3 m_end_position
Stores the end of the rubber band (i.e.
Definition: rubber_band.hpp:76
RubberBandTo
Definition: rubber_band.hpp:52
@ RB_TO_TRACK
Rubber band is attached to track.
Definition: rubber_band.hpp:55
@ RB_TO_KART
Rubber band is attached to a kart hit.
Definition: rubber_band.hpp:54
@ RB_TO_PLUNGER
Rubber band is attached to plunger.
Definition: rubber_band.hpp:53
AbstractKart * m_hit_kart
The kart a plunger might have hit.
Definition: rubber_band.hpp:73
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35