Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[supertux.git] / src / object / moving_sprite.hpp
1 //  SuperTux - MovingSprite Base Class
2 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.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_MOVING_SPRITE_HPP
18 #define HEADER_SUPERTUX_OBJECT_MOVING_SPRITE_HPP
19
20 #include "object/anchor_point.hpp"
21 #include "supertux/moving_object.hpp"
22 #include "util/reader_fwd.hpp"
23 #include "video/drawing_request.hpp"
24
25 class Sprite;
26
27 /**
28  * Abstract base class for MovingObjects that are represented by a Sprite
29  */
30 class MovingSprite : public MovingObject
31 {
32 public:
33   MovingSprite(const Vector& pos, 
34                const std::string& sprite_name, 
35                int layer = LAYER_OBJECTS, 
36                CollisionGroup collision_group = COLGROUP_MOVING);
37   MovingSprite(const Reader& reader, 
38                const Vector& pos, 
39                int layer = LAYER_OBJECTS, 
40                CollisionGroup collision_group = COLGROUP_MOVING);
41   MovingSprite(const Reader& reader, 
42                const std::string& sprite_name, 
43                int layer = LAYER_OBJECTS, 
44                CollisionGroup collision_group = COLGROUP_MOVING);
45   MovingSprite(const Reader& reader, 
46                int layer = LAYER_OBJECTS, 
47                CollisionGroup collision_group = COLGROUP_MOVING);
48   MovingSprite(const MovingSprite& moving_sprite);
49   //MovingSprite& operator=(const MovingSprite& moving_sprite);
50   ~MovingSprite();
51
52   virtual void draw(DrawingContext& context);
53   virtual void update(float elapsed_time);
54
55 protected:
56   std::string sprite_name;
57   std::auto_ptr<Sprite> sprite;
58   int layer; /**< Sprite's z-position. Refer to video/drawing_context.hpp for sensible values. */
59
60   /** set new action for sprite and resize bounding box.  use with
61       care as you can easily get stuck when resizing the bounding box. */
62   void set_action(const std::string& action, int loops);
63
64   /** set new action for sprite and re-center bounding box.  use with
65       care as you can easily get stuck when resizing the bounding
66       box. */
67   void set_action_centered(const std::string& action, int loops);
68
69   /** set new action for sprite and align bounding boxes at
70       anchorPoint.  use with care as you can easily get stuck when
71       resizing the bounding box. */
72   void set_action(const std::string& action, int loops, AnchorPoint anchorPoint);
73
74 private:
75   //MovingSprite(const MovingSprite&);
76   MovingSprite& operator=(const MovingSprite&);
77 };
78
79 #endif
80
81 /* EOF */