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 |
19 | |
20 | #include "object/moving_sprite.hpp" |
21 | #include "supertux/physic.hpp" |
22 | |
23 | class Player; |
24 | |
25 | /** This class is the base class for icecrushers that tux can stand on */ |
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 _("Icecrusher" ); } |
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 */ |
79 | |