Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[supertux.git] / src / object / background.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_OBJECT_BACKGROUND_HPP
18 #define HEADER_SUPERTUX_OBJECT_BACKGROUND_HPP
19
20 #include "supertux/game_object.hpp"
21 #include "util/reader_fwd.hpp"
22 #include "video/drawing_context.hpp"
23
24 class DisplayManager;
25
26 class Background : public GameObject
27 {
28 public:
29   Background();
30   Background(const Reader& reader);
31   virtual ~Background();
32
33   void set_image(const std::string& name, float bkgd_speed);
34
35   std::string get_image() const
36   { return imagefile; }
37   float get_speed() const
38   { return speed; }
39
40   virtual void update(float elapsed_time);
41
42   virtual void draw(DrawingContext& context);
43
44 private:
45   int layer;
46   std::string imagefile_top;
47   std::string imagefile;
48   std::string imagefile_bottom;
49   Vector pos; /**< coordinates of upper-left corner of image */
50   float speed; /**< scroll-speed in horizontal direction */
51   float speed_y; /**< scroll-speed in vertical direction */
52   std::auto_ptr<Surface> image_top; /**< image to draw above pos */
53   std::auto_ptr<Surface> image; /**< image to draw, anchored at pos */
54   std::auto_ptr<Surface> image_bottom; /**< image to draw below pos+screenheight */
55 };
56
57 #endif /*SUPERTUX_BACKGROUND_H*/
58
59 /* EOF */