Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[supertux.git] / src / worldmap / sprite_change.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.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_WORLDMAP_SPRITE_CHANGE_HPP
18 #define HEADER_SUPERTUX_WORLDMAP_SPRITE_CHANGE_HPP
19
20 #include <list>
21 #include <memory>
22 #include <string>
23
24 #include "lisp/lisp.hpp"
25 #include "math/vector.hpp"
26 #include "supertux/game_object.hpp"
27
28 class Sprite;
29
30 namespace WorldMapNS {
31
32 class SpriteChange : public GameObject
33 {
34 public:
35   SpriteChange(const lisp::Lisp* lisp);
36   virtual ~SpriteChange();
37
38   Vector pos;
39   /**
40    * should tuxs sprite change when the tile has been completely entered,
41    * or already when the tile was just touched
42    */
43   bool change_on_touch;
44   /// sprite to change tux image to
45   std::auto_ptr<Sprite> sprite;
46   /**
47    * stay action can be used for objects like boats or cars, if it is
48    * != "" then this sprite will be displayed when tux left the tile towards
49    * another SpriteChange object.
50    */
51   std::string stay_action;
52
53   /**
54    * name of a group in which only one SpriteChange will ever have its stay_action displayed.
55    * Leave empty if you don't care.
56    */
57   std::string stay_group;
58
59   virtual void draw(DrawingContext& context);
60   virtual void update(float elapsed_time);
61
62   /**
63    * Activates the SpriteChange's stay action, if applicable
64    */
65   void set_stay_action();
66
67   /**
68    * Deactivates the SpriteChange's stay action, if applicable
69    */
70   void clear_stay_action();
71
72 private:
73   /**
74    * should the stayaction be displayed
75    */
76   bool in_stay_action;
77
78   static std::list<SpriteChange*> all_sprite_changes;
79
80 };
81
82 }
83
84 #endif
85
86 /* EOF */