Getting rid of nasty tabs
[supertux.git] / src / object / icecrusher.hpp
1 //  $Id$
2 //
3 //  IceCrusher - A block to stand on, which can drop down to crush the player
4 //  Copyright (C) 2008 Christoph Sommer <christoph.sommer@2008.expires.deltadevelopment.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (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, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20
21 #ifndef INCLUDED_ICECRUSHER_HPP
22 #define INCLUDED_ICECRUSHER_HPP
23
24 #include <memory>
25 #include <string>
26 #include "object/moving_sprite.hpp"
27 #include "object/player.hpp"
28
29 /**
30  * This class is the base class for icecrushers that tux can stand on
31  */
32 class IceCrusher : public MovingSprite
33 {
34   public:
35     IceCrusher(const lisp::Lisp& reader);
36     IceCrusher(const IceCrusher& icecrusher);
37     virtual IceCrusher* clone() const { return new IceCrusher(*this); }
38
39     virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
40     virtual void collision_solid(const CollisionHit& hit);
41     virtual void update(float elapsed_time);
42
43     const Vector& get_speed() const
44     {
45       return speed;
46     }
47
48   protected:
49     enum IceCrusherState {
50       IDLE,
51       CRUSHING,
52       RECOVERING
53     };
54     IceCrusherState state;
55     Vector start_position;
56     Vector speed;
57
58     Player* get_nearest_player();
59     bool found_victim();
60     void set_state(IceCrusherState state, bool force = false);
61
62 };
63
64 #endif