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  virtual ~TreeWillOWisp();
30 
31  virtual void activate() override;
32  virtual void active_update(float dt_sec) override;
33 
34  virtual bool is_flammable() const override { return false; }
35  virtual bool is_freezable() const override { return false; }
36  virtual void kill_fall() override { vanish(); }
37 
38  virtual void draw(DrawingContext& context) override;
39 
40  virtual void stop_looping_sounds() override;
41  virtual void play_looping_sounds() override;
42 
44  void vanish();
45  void start_sucking(const Vector& suck_target);
46 
47  void set_color(const Color& color);
48  Color get_color() const;
49 
50 protected:
51  virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
52  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
53 
54 private:
55  enum MyState {
56  STATE_DEFAULT, STATE_VANISHING, STATE_SUCKED
57  };
58 
59 public:
60  bool was_sucked;
61 
62 private:
63  MyState mystate;
64 
65  Color color;
66  float angle;
67  float radius;
68  float speed;
69 
70  std::unique_ptr<SoundSource> sound_source;
71  GhostTree* tree;
72 
73  Vector suck_target;
74 
75 private:
76  TreeWillOWisp(const TreeWillOWisp&) = delete;
77  TreeWillOWisp& operator=(const TreeWillOWisp&) = delete;
78 };
79 
80 #endif
81 
82 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:31
virtual bool collides(GameObject &other, const CollisionHit &hit) const override
when 2 objects collided, we will first call the pre_collision_check functions of both objects that ca...
Definition: treewillowisp.cpp:88
Simple two dimensional vector.
Definition: vector.hpp:24
virtual void activate() override
called when the badguy has been activated.
Definition: treewillowisp.cpp:54
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:36
Definition: treewillowisp.hpp:25
virtual void play_looping_sounds() override
continues all looping sounds
Definition: treewillowisp.cpp:164
Definition: ghosttree.hpp:25
virtual void stop_looping_sounds() override
stops all looping sounds
Definition: treewillowisp.cpp:157
virtual bool is_flammable() const override
Returns whether to call ignite() when a badguy gets hit by a fire bullet.
Definition: treewillowisp.hpp:34
void vanish()
make TreeWillOWisp vanish
Definition: treewillowisp.cpp:65
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: treewillowisp.cpp:81
A sound source represents the source of audio output.
Definition: sound_source.hpp:25
Definition: color.hpp:25
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: treewillowisp.cpp:100
Definition: player.hpp:39
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:107