2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
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.
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.
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/>.
17 #ifndef HEADER_SUPERTUX_OBJECT_BACKGROUND_HPP
18 #define HEADER_SUPERTUX_OBJECT_BACKGROUND_HPP
20 #include "supertux/game_object.hpp"
21 #include "util/reader_fwd.hpp"
22 #include "video/drawing_context.hpp"
26 class Background : public GameObject
30 Background(const Reader& reader);
31 virtual ~Background();
33 void set_image(const std::string& name, float bkgd_speed);
35 std::string get_image() const
37 float get_speed() const
40 virtual void update(float elapsed_time);
42 virtual void draw(DrawingContext& context);
43 void draw_image(DrawingContext& context, const Vector& pos);
54 /** Backgrounds with NO_ALIGNMENT are repeated over the whole
55 screen, backgrounds with left, right, top, bottom alignment are
56 only repeated in one direction and attached to the level edge */
60 std::string imagefile_top;
61 std::string imagefile;
62 std::string imagefile_bottom;
63 Vector pos; /**< coordinates of upper-left corner of image */
64 float speed; /**< scroll-speed in horizontal direction */
65 float speed_y; /**< scroll-speed in vertical direction */
68 std::auto_ptr<Surface> image_top; /**< image to draw above pos */
69 std::auto_ptr<Surface> image; /**< image to draw, anchored at pos */
70 std::auto_ptr<Surface> image_bottom; /**< image to draw below pos+screenheight */
73 #endif /*SUPERTUX_BACKGROUND_H*/