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 setNum (int n = 1);
59  void reset ();
60  Material* getIcon () const;
61  void adjustSound ();
62  void use ();
63  void hitBonusBox (const ItemState &item);
64  void saveState(BareNetworkString *buffer) const;
65  void rewindTo(BareNetworkString *buffer);
66  void update(int ticks);
67 
69  int getNum () const {return m_number;}
70  // ------------------------------------------------------------------------
72  PowerupManager::PowerupType
73  getType () const {return m_type; }
74  // ------------------------------------------------------------------------
75 };
76 
77 #endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Contains the state information of an item, i.e.
Definition: item.hpp:53
Definition: material.hpp:48
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: powerup.hpp:38
AbstractKart * m_kart
The owner (kart) of this powerup.
Definition: powerup.hpp:50
void set(PowerupManager::PowerupType _type, int n=1)
Sets the collected items.
Definition: powerup.cpp:136
~Powerup()
Frees the memory for the sound effects.
Definition: powerup.cpp:55
void reset()
Resets the powerup, called at begin of a race.
Definition: powerup.cpp:63
int getNum() const
Returns the number of powerups.
Definition: powerup.hpp:69
void rewindTo(BareNetworkString *buffer)
Restore a powerup state.
Definition: powerup.cpp:92
void setNum(int n=1)
Sets the amount of the current collected item.
Definition: powerup.cpp:201
PowerupManager::PowerupType m_type
The powerup type.
Definition: powerup.hpp:44
Material * getIcon() const
Returns the icon for the currently collected powerup.
Definition: powerup.cpp:213
Powerup(AbstractKart *kart_)
Constructor, stores the kart to which this powerup belongs.
Definition: powerup.cpp:45
SFXBase * m_sound_use
Sound effect that is being played.
Definition: powerup.hpp:41
void use()
Use (fire) this powerup.
Definition: powerup.cpp:247
void saveState(BareNetworkString *buffer) const
Save the powerup state.
Definition: powerup.cpp:81
PowerupManager::PowerupType getType() const
Returns the type of this powerup.
Definition: powerup.hpp:73
void hitBonusBox(const ItemState &item)
This function is called when a bnous box is it.
Definition: powerup.cpp:508
void adjustSound()
Does the sound configuration.
Definition: powerup.cpp:223
int m_number
Number of collected powerups.
Definition: powerup.hpp:47
The base class for sound effects.
Definition: sfx_base.hpp:43