supertux
goldbomb.hpp
1 // SuperTux BadGuy GoldBomb - a bomb that throws up coins when exploding
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // Copyright (C) 2013 LMH <lmh.0013@gmail.com>
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (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, see <http://www.gnu.org/licenses/>.
17 
18 
19 #ifndef HEADER_SUPERTUX_BADGUY_GOLDBOMB_HPP
20 #define HEADER_SUPERTUX_BADGUY_GOLDBOMB_HPP
21 
22 #include "badguy/walking_badguy.hpp"
23 #include "object/portable.hpp"
24 
25 class SoundSource;
26 
27 class GoldBomb final : public WalkingBadguy, public Portable
28 {
29 public:
30  GoldBomb(const ReaderMapping& reader);
31 
32  virtual void collision_solid(const CollisionHit& hit) override;
33  virtual HitResponse collision(GameObject& object, const CollisionHit& hit) override;
34  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
35  virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override;
36 
37  virtual void active_update(float dt_sec) override;
38 
39  virtual void grab(MovingObject& object, const Vector& pos, Direction dir) override;
40  virtual void ungrab(MovingObject& object, Direction dir) override;
41  virtual bool is_portable() const override;
42 
43  virtual void freeze() override;
44  virtual bool is_freezable() const override;
45 
46  virtual void kill_fall() override;
47  virtual void ignite() override;
48  virtual std::string get_class() const override { return "goldbomb"; }
49  virtual std::string get_display_name() const override { return _("Golden bomb"); }
50 
51  virtual void stop_looping_sounds() override;
52  virtual void play_looping_sounds() override;
53 
54 protected:
55  virtual bool collision_squished(GameObject& object) override;
56 
57 private:
58  enum Ticking_State {
59  STATE_NORMAL,
60  STATE_TICKING
61  };
62 
63 private:
64  Ticking_State tstate;
65  bool grabbed;
66  MovingObject* grabber;
67 
68  std::unique_ptr<SoundSource> ticking;
69 
70 private:
71  GoldBomb(const GoldBomb&) = delete;
72  GoldBomb& operator=(const GoldBomb&) = delete;
73 };
74 
75 #endif
76 
77 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:31
Definition: goldbomb.hpp:27
virtual void play_looping_sounds() override
continues all looping sounds
Definition: goldbomb.cpp:262
Simple two dimensional vector.
Definition: vector.hpp:24
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: goldbomb.cpp:135
virtual void ignite() override
Called when hit by a fire bullet, and is_flammable() returns true.
Definition: goldbomb.cpp:179
virtual void grab(MovingObject &object, const Vector &pos, Direction dir) override
called each frame when the object has been grabbed.
Definition: goldbomb.cpp:185
An object that inherits from this object is considered "portable" and can be carried around by the pl...
Definition: portable.hpp:29
virtual bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: goldbomb.cpp:107
Base class for Badguys that walk on the floor.
Definition: walking_badguy.hpp:25
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: goldbomb.cpp:56
virtual HitResponse collision(GameObject &object, const CollisionHit &hit) override
Called when a collision with another object occurred.
Definition: goldbomb.cpp:73
virtual void stop_looping_sounds() override
stops all looping sounds
Definition: goldbomb.cpp:255
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:31
A sound source represents the source of audio output.
Definition: sound_source.hpp:25
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: goldbomb.cpp:99
virtual void kill_fall() override
Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned ups...
Definition: goldbomb.cpp:154
Definition: reader_mapping.hpp:31
Definition: player.hpp:39
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: goldbomb.cpp:89
virtual void freeze() override
Called when hit by an ice bullet, and is_freezable() returns true.
Definition: goldbomb.cpp:236
This class collects data about a collision.
Definition: collision_hit.hpp:44