supertux
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 
26 class UnstableTile final : public MovingSprite
27 {
28 public:
29  UnstableTile(const ReaderMapping& mapping);
30 
31  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
32  virtual void update(float dt_sec) override;
33  virtual std::string get_class() const override { return "unstable_tile"; }
34  virtual std::string get_display_name() const override { return _("Unstable tile"); }
35 
36 private:
37  enum State {
38  STATE_NORMAL,
39  STATE_SHAKE,
40  STATE_DISSOLVE,
41  STATE_SLOWFALL,
42  STATE_FALL
43  };
44 
45 private:
46  void startCrumbling();
47  void shake();
48  void dissolve();
49  void fall_down();
50  void slow_fall();
51 
52 private:
53  Physic physic;
54  State state;
55  float slowfall_timer;
56 
57 private:
58  UnstableTile(const UnstableTile&) = delete;
59  UnstableTile& operator=(const UnstableTile&) = delete;
60 };
61 
62 #endif
63 
64 /* EOF */
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: unstable_tile.cpp:119
Physics engine.
Definition: physic.hpp:27
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
Definition: reader_mapping.hpp:31
Abstract base class for MovingObjects that are represented by a Sprite.
Definition: moving_sprite.hpp:29
A block that disintegrates when stood on.
Definition: unstable_tile.hpp:26
This class collects data about a collision.
Definition: collision_hit.hpp:44
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: unstable_tile.cpp:38