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/boss.hpp"
22 
23 class Yeti final : public Boss
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 HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override;
34  virtual void kill_fall() override;
35 
36  static std::string class_name() { return "yeti"; }
37  virtual std::string get_class_name() const override { return class_name(); }
38  static std::string display_name() { return _("Yeti"); }
39  virtual std::string get_display_name() const override { return display_name(); }
40  virtual GameObjectClasses get_class_types() const override { return Boss::get_class_types().add(typeid(Yeti)); }
41 
42  virtual ObjectSettings get_settings() override;
43 
44  void kill_squished(GameObject& object);
45 
46 protected:
47  virtual std::vector<Direction> get_allowed_directions() const override;
48 
49 private:
50  void run();
51  void jump_up();
52  void throw_snowballs();
53  void throw_big_snowballs();
54  void be_angry();
55  void drop_stalactite();
56  void summon_snowball();
57  void summon_big_snowball();
58 
59  void take_hit(Player& player);
60 
61  void add_snow_explosions();
62  void recalculate_pos();
63 
64 private:
65  enum YetiState {
66  RUN,
67  JUMP_UP,
68  THROW,
69  THROW_BIG,
70  BE_ANGRY,
71  SQUISHED,
72  FALLING,
73  REMOVE_TUX
74  };
75 
76 private:
77  YetiState m_state;
78  Timer m_state_timer;
79  Timer m_safe_timer;
80  int m_stomp_count;
81 
82  float m_left_stand_x;
83  float m_right_stand_x;
84  float m_left_jump_x;
85  float m_right_jump_x;
86 
87  bool m_fixed_pos;
88  bool m_just_hit;
89  bool m_just_threw;
90  bool m_grabbed_tux;
91  bool m_jumped;
92 
93  class SnowExplosionParticle: public BadGuy
94  {
95  public:
96  SnowExplosionParticle(const Vector& pos, const Vector& velocity);
97  virtual GameObjectClasses get_class_types() const override { return BadGuy::get_class_types().add(typeid(Yeti::SnowExplosionParticle)); }
98  };
99 
100 private:
101  Yeti(const Yeti&) = delete;
102  Yeti& operator=(const Yeti&) = delete;
103 };
104 
105 #endif
106 
107 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: yeti.cpp:125
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
Definition: yeti.hpp:23
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: boss.hpp:33
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: yeti.cpp:115
virtual void initialize() override
called immediately before the first call to initialize
Definition: yeti.cpp:93
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: yeti.cpp:422
virtual bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: yeti.cpp:318
Definition: object_settings.hpp:39
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:374
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: yeti.hpp:40
virtual std::vector< Direction > get_allowed_directions() const override
Returns a vector of directions the badguy can be set to.
Definition: yeti.cpp:515
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: yeti.hpp:39
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
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: yeti.cpp:329
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:32
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