move over rewritten lispreader from tuxkart (with additional fixes), generalized...
[supertux.git] / src / object / background.h
1 //  $Id$
2 //
3 //  SuperTux -  A Jump'n Run
4 //  Copyright (C) 2004 Matthias Braun <matze@braunis.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  02111-1307, USA.
19
20 #ifndef SUPERTUX_BACKGROUND_H
21 #define SUPERTUX_BACKGROUND_H
22
23 #include "video/surface.h"
24 #include "video/drawing_context.h"
25 #include "special/game_object.h"
26 #include "serializable.h"
27
28 class DisplayManager;
29
30 namespace lisp {
31 class Lisp;
32 }
33
34 class Background : public GameObject, public Serializable
35 {
36 public:
37   Background();
38   Background(const lisp::Lisp& reader);
39   virtual ~Background();
40
41   virtual void write(lisp::Writer& writer);
42
43   void set_image(const std::string& name, float bkgd_speed);
44
45   void set_gradient(Color top, Color bottom);
46
47   std::string get_image() const
48         { return imagefile; }
49   float get_speed() const
50         { return speed; }
51   Color get_gradient_top() const
52         { return gradient_top; }
53   Color get_gradient_bottom() const
54         { return gradient_bottom; }
55
56   virtual void action(float elapsed_time);
57
58   virtual void draw(DrawingContext& context);
59
60 private:
61   enum Type {
62     INVALID, GRADIENT, IMAGE      
63   };
64   
65   Type type;
66   int layer;
67   std::string imagefile;
68   float speed;
69   Surface* image;
70   Color gradient_top, gradient_bottom;
71 };
72
73 #endif /*SUPERTUX_BACKGROUND_H*/
74