supertux
yeti.hpp
1 // SuperTux - Boss "Yeti"
2 // Copyright (C) 2005 Matthias Braun <matze@braunis.de>
3 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
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 #ifndef HEADER_SUPERTUX_BADGUY_YETI_HPP
19 #define HEADER_SUPERTUX_BADGUY_YETI_HPP
20 
21 #include "badguy/badguy.hpp"
22 
23 class Yeti final : public BadGuy
24 {
25 public:
26  Yeti(const ReaderMapping& mapping);
27 
28  virtual void draw(DrawingContext& context) override;
29  virtual void initialize() override;
30  virtual void active_update(float dt_sec) override;
31  virtual void collision_solid(const CollisionHit& hit) override;
32  virtual bool collision_squished(GameObject& object) override;
33  virtual void kill_fall() override;
34 
35  virtual bool is_flammable() const override;
36  virtual std::string get_class() const override { return "yeti"; }
37  virtual std::string get_display_name() const override { return _("Yeti"); }
38 
39  virtual ObjectSettings get_settings() override;
40 
41  void kill_squished(GameObject& object);
42 
43 private:
44  void run();
45  void jump_up();
46  void be_angry();
47  void drop_stalactite();
48  void jump_down();
49 
50  void draw_hit_points(DrawingContext& context);
51 
52  void take_hit(Player& player);
53 
54  void add_snow_explosions();
55 
56 private:
57  enum YetiState {
58  JUMP_DOWN,
59  RUN,
60  JUMP_UP,
61  BE_ANGRY,
62  SQUISHED,
63  FALLING
64  };
65 
66 private:
67  YetiState state;
68  Timer state_timer;
69  Timer safe_timer;
70  int stomp_count;
71  int hit_points;
72  SurfacePtr hud_head;
73 
74  float left_stand_x;
75  float right_stand_x;
76  float left_jump_x;
77  float right_jump_x;
78 
79  void recalculate_pos();
80 
81  bool fixed_pos;
82  std::string hud_icon;
83 
84  class SnowExplosionParticle: public BadGuy
85  {
86  public:
87  SnowExplosionParticle(const Vector& pos, const Vector& velocity);
88  };
89 
90 private:
91  Yeti(const Yeti&) = delete;
92  Yeti& operator=(const Yeti&) = delete;
93 };
94 
95 #endif
96 
97 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:31
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: yeti.cpp:145
Definition: yeti.hpp:23
Simple two dimensional vector.
Definition: vector.hpp:24
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: yeti.cpp:116
virtual void initialize() override
called immediately before the first call to initialize
Definition: yeti.cpp:94
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: yeti.cpp:315
virtual bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: yeti.cpp:236
Definition: object_settings.hpp:35
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: yeti.cpp:280
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: yeti.cpp:358
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:31
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