supertux
ghosttree.hpp
1 // SuperTux - Boss "GhostTree"
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_GHOSTTREE_HPP
18 #define HEADER_SUPERTUX_BADGUY_GHOSTTREE_HPP
19 
20 #include "badguy/boss.hpp"
21 
22 class TreeWillOWisp;
23 class Lantern;
24 
25 class GhostTree final : public Boss
26 {
27 public:
28  GhostTree(const ReaderMapping& mapping);
29 
30  virtual void kill_fall() override { }
31 
32  virtual void activate() override;
33  virtual void active_update(float dt_sec) override;
34  virtual void draw(DrawingContext& context) override;
35 
36  virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
37  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
38 
39  static std::string class_name() { return "ghosttree"; }
40  virtual std::string get_class_name() const override { return class_name(); }
41  static std::string display_name() { return _("Ghost Tree"); }
42  virtual std::string get_display_name() const override { return display_name(); }
43  virtual GameObjectClasses get_class_types() const override { return Boss::get_class_types().add(typeid(GhostTree)); }
44 
45  virtual void on_flip(float height) override;
46 
47  void willowisp_died(TreeWillOWisp* willowisp);
48  void die();
49 
50 protected:
51  virtual std::vector<Direction> get_allowed_directions() const override;
52 
53 private:
54  enum MyState {
55  STATE_IDLE, STATE_SUCKING, STATE_SWALLOWING, STATE_DYING
56  };
57 
58 private:
59  bool is_color_deadly(Color color) const;
60  void spawn_lantern();
61 
62 private:
63  MyState mystate;
64  Timer willowisp_timer;
65  float willo_spawn_y;
66  float willo_radius;
67  float willo_speed;
68  int willo_color;
69 
70  SpritePtr glow_sprite;
71  Timer colorchange_timer;
72  Timer suck_timer;
73  Timer root_timer;
74  int treecolor;
75  Color suck_lantern_color;
76 
77  bool m_taking_life;
78 
79  Lantern* suck_lantern;
81  std::vector<TreeWillOWisp*> willowisps;
82 
83 private:
84  GhostTree(const GhostTree&) = delete;
85  GhostTree& operator=(const GhostTree&) = delete;
86 };
87 
88 #endif
89 
90 /* EOF */
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: ghosttree.cpp:248
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: boss.hpp:33
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
Called when a collision with another object occurred.
Definition: ghosttree.cpp:257
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: ghosttree.hpp:30
Definition: treewillowisp.hpp:25
Definition: ghosttree.hpp:25
Lantern.
Definition: lantern.hpp:23
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: ghosttree.cpp:91
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: ghosttree.cpp:233
virtual std::vector< Direction > get_allowed_directions() const override
Returns a vector of directions the badguy can be set to.
Definition: ghosttree.cpp:284
virtual void activate() override
called when the badguy has been activated.
Definition: ghosttree.cpp:83
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: ghosttree.cpp:290
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: ghosttree.hpp:43
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: ghosttree.hpp:42
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
Definition: boss.hpp:25
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:32
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