supertux
icecrusher.hpp
1 // IceCrusher - A block to stand on, which can drop down to crush the player
2 // Copyright (C) 2008 Christoph Sommer <christoph.sommer@2008.expires.deltadevelopment.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_OBJECT_ICECRUSHER_HPP
18 #define HEADER_SUPERTUX_OBJECT_ICECRUSHER_HPP
19 
20 #include "object/moving_sprite.hpp"
21 #include "supertux/physic.hpp"
22 
23 class Player;
24 
26 class IceCrusher final : public MovingSprite
27 {
28 private:
29  enum IceCrusherState {
30  IDLE,
31  CRUSHING,
32  RECOVERING
33  };
34 
35  enum IceCrusherSize {
36  NORMAL,
37  LARGE
38  };
39 
40 public:
41  IceCrusher(const ReaderMapping& reader);
42 
43  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
44  virtual void collision_solid(const CollisionHit& hit) override;
45  virtual void update(float dt_sec) override;
46  virtual void draw(DrawingContext& context) override;
47  virtual std::string get_class() const override { return "icecrusher"; }
48  virtual std::string get_display_name() const override { return _("Ice crusher"); }
49 
50  virtual void after_editor_set() override;
51 
52 private:
53  bool found_victim() const;
54  void set_state(IceCrusherState state, bool force = false);
55  Vector eye_position(bool right) const;
56 
57  void after_sprite_set();
58 
59 private:
60  IceCrusherState state;
61  Vector start_position;
62  Physic physic;
63  float cooldown_timer;
64 
65  SpritePtr lefteye;
66  SpritePtr righteye;
67  SpritePtr whites;
68 
69  IceCrusherSize ic_size;
70 
71 private:
72  IceCrusher(const IceCrusher&) = delete;
73  IceCrusher& operator=(const IceCrusher&) = delete;
74 };
75 
76 #endif
77 
78 /* EOF */
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: icecrusher.cpp:237
Simple two dimensional vector.
Definition: vector.hpp:24
Physics engine.
Definition: physic.hpp:27
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: icecrusher.cpp:189
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: icecrusher.cpp:98
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
This class is the base class for icecrushers that tux can stand on.
Definition: icecrusher.hpp:26
virtual void collision_solid(const CollisionHit &hit) override
this function is called when the object collided with something solid
Definition: icecrusher.cpp:127
Definition: reader_mapping.hpp:31
Abstract base class for MovingObjects that are represented by a Sprite.
Definition: moving_sprite.hpp:29
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