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/badguy.hpp"
21 
22 class TreeWillOWisp;
23 class Lantern;
24 
25 class GhostTree final : public BadGuy
26 {
27 public:
28  GhostTree(const ReaderMapping& mapping);
29 
30  virtual bool is_flammable() const override { return false; }
31  virtual bool is_freezable() const override { return false; }
32  virtual void kill_fall() override { }
33 
34  virtual void activate() override;
35  virtual void active_update(float dt_sec) override;
36  virtual void draw(DrawingContext& context) override;
37 
38  virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
39  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
40 
41  virtual std::string get_class() const override { return "ghosttree"; }
42  virtual std::string get_display_name() const override { return _("Ghost tree"); }
43 
44  void willowisp_died(TreeWillOWisp* willowisp);
45  void die();
46 
47 private:
48  enum MyState {
49  STATE_IDLE, STATE_SUCKING, STATE_SWALLOWING, STATE_DYING
50  };
51 
52 private:
53  bool is_color_deadly(Color color) const;
54  void spawn_lantern();
55 
56 private:
57  MyState mystate;
58  Timer willowisp_timer;
59  float willo_spawn_y;
60  float willo_radius;
61  float willo_speed;
62  int willo_color;
63 
64  SpritePtr glow_sprite;
65  Timer colorchange_timer;
66  Timer suck_timer;
67  Timer root_timer;
68  int treecolor;
69  Color suck_lantern_color;
70 
71  Lantern* suck_lantern;
73  std::vector<TreeWillOWisp*> willowisps;
74 
75 private:
76  GhostTree(const GhostTree&) = delete;
77  GhostTree& operator=(const GhostTree&) = 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: ghosttree.cpp:229
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
Called when a collision with another object occurred.
Definition: ghosttree.cpp:238
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:32
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:82
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: ghosttree.cpp:214
virtual void activate() override
called when the badguy has been activated.
Definition: ghosttree.cpp:74
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual bool is_flammable() const override
Returns whether to call ignite() when a badguy gets hit by a fire bullet.
Definition: ghosttree.hpp:30
Definition: color.hpp:25
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:31
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