Fix all #29358 issues
[supertux.git] / src / object / unstable_tile.hpp
1 //  SuperTux - Unstable Tile
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
4 //  Copyright (C) 2010 Florian Forster <supertux at octo.it>
5 //
6 //  This program is free software: you can redistribute it and/or modify
7 //  it under the terms of the GNU General Public License as published by
8 //  the Free Software Foundation, either version 3 of the License, or
9 //  (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 #ifndef HEADER_SUPERTUX_OBJECT_UNSTABLE_TILE_HPP
20 #define HEADER_SUPERTUX_OBJECT_UNSTABLE_TILE_HPP
21
22 #include "object/moving_sprite.hpp"
23 #include "supertux/physic.hpp"
24 #include "supertux/timer.hpp"
25
26 /**
27  * A block that disintegrates when stood on
28  */
29 class UnstableTile : public MovingSprite
30 {
31 public:
32   UnstableTile(const Reader& lisp);
33
34   HitResponse collision(GameObject& other, const CollisionHit& hit);
35   void update(float elapsed_time);
36
37 private:
38   enum State {
39     STATE_NORMAL,   /**< default state */
40     STATE_SHAKE,    /**< shaking, still solid */
41     STATE_DISSOLVE, /**< dissolving, will turn non-solid after this */
42     STATE_SLOWFALL, /**< slow fall phase (used when neither shaking nor dissolving exist */
43     STATE_FALL      /**< falling down */
44   };
45
46   void startCrumbling();
47
48 private:
49   void shake (void);
50   void dissolve (void);
51   void fall_down (void);
52   void slow_fall (void);
53
54   Physic physic;
55   State state;
56   float slowfall_timer;
57 };
58
59 #endif
60
61 /* EOF */