SuperTuxKart
powerup.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2006-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_POWERUP_HPP
20 #define HEADER_POWERUP_HPP
21 
22 #define MAX_POWERUPS 5
23 
24 #include "items/powerup_manager.hpp" // needed for powerup_type
25 #include "utils/no_copy.hpp"
26 
27 #include <set>
28 
29 class AbstractKart;
30 class BareNetworkString;
31 class ItemState;
32 class SFXBase;
33 
37 class Powerup : public NoCopy
38 {
39 private:
42 
44  PowerupManager::PowerupType m_type;
45 
47  int m_number;
48 
51 
52  std::set<int> m_played_sound_ticks;
53 
54 public:
55  Powerup (AbstractKart* kart_);
56  ~Powerup ();
57  void set (PowerupManager::PowerupType _type, int n=1);
58  void reset ();
59  Material* getIcon () const;
60  void adjustSound ();
61  void use ();
62  void hitBonusBox (const ItemState &item);
63  void saveState(BareNetworkString *buffer) const;
64  void rewindTo(BareNetworkString *buffer);
65  void update(int ticks);
66 
68  int getNum () const {return m_number;}
69  // ------------------------------------------------------------------------
71  PowerupManager::PowerupType
72  getType () const {return m_type; }
73  // ------------------------------------------------------------------------
74 };
75 
76 #endif
AbstractKart * m_kart
The owner (kart) of this powerup.
Definition: powerup.hpp:50
PowerupManager::PowerupType m_type
The powerup type.
Definition: powerup.hpp:44
void saveState(BareNetworkString *buffer) const
Save the powerup state.
Definition: powerup.cpp:81
void rewindTo(BareNetworkString *buffer)
Restore a powerup state.
Definition: powerup.cpp:92
void hitBonusBox(const ItemState &item)
This function is called when a bnous box is it.
Definition: powerup.cpp:500
Definition: powerup.hpp:37
void set(PowerupManager::PowerupType _type, int n=1)
Sets the collected items.
Definition: powerup.cpp:136
PowerupManager::PowerupType getType() const
Returns the type of this powerup.
Definition: powerup.hpp:72
~Powerup()
Frees the memory for the sound effects.
Definition: powerup.cpp:55
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
void reset()
Resets the powerup, called at begin of a race.
Definition: powerup.cpp:63
Powerup(AbstractKart *kart_)
Constructor, stores the kart to which this powerup belongs.
Definition: powerup.cpp:45
int getNum() const
Returns the number of powerups.
Definition: powerup.hpp:68
Material * getIcon() const
Returns the icon for the currently collected powerup.
Definition: powerup.cpp:205
Definition: material.hpp:46
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
void use()
Use (fire) this powerup.
Definition: powerup.cpp:239
void adjustSound()
Does the sound configuration.
Definition: powerup.cpp:215
The base class for sound effects.
Definition: sfx_base.hpp:42
SFXBase * m_sound_use
Sound effect that is being played.
Definition: powerup.hpp:41
Contains the state information of an item, i.e.
Definition: item.hpp:52
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
int m_number
Number of collected powerups.
Definition: powerup.hpp:47