supertux
treewillowisp.hpp
1 // SuperTux - "Will-O-Wisp" Badguy
2 // Copyright (C) 2007 Matthias Braun <matze@braunis.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_BADGUY_TREEWILLOWISP_HPP
18 #define HEADER_SUPERTUX_BADGUY_TREEWILLOWISP_HPP
19 
20 #include "badguy/badguy.hpp"
21 
22 class GhostTree;
23 class SoundSource;
24 
25 class TreeWillOWisp final : public BadGuy
26 {
27 public:
28  TreeWillOWisp(GhostTree* tree, const Vector& pos, float radius, float speed);
29  ~TreeWillOWisp() override;
30  virtual GameObjectClasses get_class_types() const override { return BadGuy::get_class_types().add(typeid(TreeWillOWisp)); }
31 
32  virtual void activate() override;
33  virtual void active_update(float dt_sec) override;
34 
35  virtual bool is_flammable() const override { return false; }
36  virtual bool is_freezable() const override { return false; }
37  virtual void kill_fall() override { vanish(); }
38 
39  virtual void draw(DrawingContext& context) override;
40 
41  virtual void stop_looping_sounds() override;
42  virtual void play_looping_sounds() override;
43 
45  void vanish();
46  void start_sucking(const Vector& suck_target);
47 
48  void set_color(const Color& color);
49  Color get_color() const;
50 
51 protected:
52  virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
53  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
54 
55 private:
56  enum MyState {
57  STATE_DEFAULT, STATE_VANISHING, STATE_SUCKED
58  };
59 
60 public:
61  bool was_sucked;
62 
63 private:
64  MyState mystate;
65 
66  Color color;
67  float angle;
68  float radius;
69  float speed;
70 
71  std::unique_ptr<SoundSource> sound_source;
72  GhostTree* tree;
73 
74  Vector suck_target;
75 
76 private:
77  TreeWillOWisp(const TreeWillOWisp&) = delete;
78  TreeWillOWisp& operator=(const TreeWillOWisp&) = delete;
79 };
80 
81 #endif
82 
83 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual bool collides(GameObject &other, const CollisionHit &hit) const override
when 2 objects collided, we will first call the collision functions of both objects that can decide o...
Definition: treewillowisp.cpp:94
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
virtual void activate() override
called when the badguy has been activated.
Definition: treewillowisp.cpp:55
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: treewillowisp.hpp:37
Definition: treewillowisp.hpp:25
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: treewillowisp.hpp:30
virtual void play_looping_sounds() override
continues all looping sounds
Definition: treewillowisp.cpp:170
Definition: ghosttree.hpp:25
virtual void stop_looping_sounds() override
stops all looping sounds
Definition: treewillowisp.cpp:163
virtual bool is_flammable() const override
Returns whether to call ignite() when a badguy gets hit by a fire bullet.
Definition: treewillowisp.hpp:35
void vanish()
make TreeWillOWisp vanish
Definition: treewillowisp.cpp:66
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: treewillowisp.cpp:87
A sound source represents the source of audio output.
Definition: sound_source.hpp:25
Definition: color.hpp:26
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: treewillowisp.cpp:106
This module contains methods controlling the player.
Definition: player.hpp:47
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
This class collects data about a collision.
Definition: collision_hit.hpp:44
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: treewillowisp.cpp:113