supertux
stalactite.hpp
1 // SuperTux
2 // Copyright (C) 2006 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_STALACTITE_HPP
18 #define HEADER_SUPERTUX_BADGUY_STALACTITE_HPP
19 
20 #include "object/sticky_object.hpp"
21 
22 class Stalactite : public StickyBadguy
23 {
24 public:
25  Stalactite(const ReaderMapping& mapping);
26 
27  virtual void active_update(float dt_sec) override;
28  virtual void collision_solid(const CollisionHit& hit) override;
29  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
30  virtual HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit) override;
31  virtual HitResponse collision_bullet(Bullet& bullet, const CollisionHit& hit) override;
32 
33  virtual GameObjectTypes get_types() const override;
34  std::string get_default_sprite_name() const override;
35 
36  virtual void kill_fall() override;
37  virtual void draw(DrawingContext& context) override;
38  virtual void deactivate() override;
39 
40  static std::string class_name() { return "stalactite"; }
41  virtual std::string get_class_name() const override { return class_name(); }
42  static std::string display_name() { return _("Stalactite"); }
43  virtual std::string get_display_name() const override { return display_name(); }
44  virtual GameObjectClasses get_class_types() const override { return StickyBadguy::get_class_types().add(typeid(Stalactite)); }
45 
46  virtual ObjectSettings get_settings() override;
47 
48  virtual void on_flip(float height) override;
49 
50  void squish();
51 
52 protected:
53  std::vector<Direction> get_allowed_directions() const override;
54 
55 protected:
56  enum StalactiteType {
57  ICE,
58  ROCK
59  };
60  enum StalactiteState {
61  STALACTITE_HANGING,
62  STALACTITE_SHAKING,
63  STALACTITE_FALLING,
64  STALACTITE_SQUISHED
65  };
66 
67 protected:
68  Timer timer;
69  StalactiteState state;
70  Vector shake_delta;
71 
72 private:
73  Stalactite(const Stalactite&) = delete;
74  Stalactite& operator=(const Stalactite&) = delete;
75 };
76 
77 #endif
78 
79 /* EOF */
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: stalactite.cpp:180
virtual void draw(DrawingContext &context) override
Called when the badguy is drawn.
Definition: stalactite.cpp:185
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual GameObjectTypes get_types() const override
Get all types of the object, if available.
Definition: stalactite.cpp:159
Definition: bullet.hpp:29
virtual HitResponse collision_badguy(BadGuy &other, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: stalactite.cpp:120
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: stalactite.cpp:54
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: stalactite.cpp:99
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: sticky_object.hpp:84
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: stalactite.cpp:110
Definition: object_settings.hpp:39
Definition: stalactite.hpp:22
virtual HitResponse collision_bullet(Bullet &bullet, const CollisionHit &hit) override
Called when the badguy collided with a bullet.
Definition: stalactite.cpp:139
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: stalactite.cpp:218
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: stalactite.hpp:44
std::vector< Direction > get_allowed_directions() const override
Returns a vector of directions the badguy can be set to.
Definition: stalactite.cpp:212
virtual void deactivate() override
called when the badguy has been deactivated
Definition: stalactite.cpp:205
This is a class for BadGuys that can stick to the sides, top and bottom of MovingObjects, such as platforms, fallblock, tilemap, etc.
Definition: sticky_object.hpp:77
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
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: stalactite.hpp:43
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