- reader.get("layer", layer);
- if(reader.get("image", imagefile)
- && reader.get("speed", speed)) {
- set_image(imagefile, speed);
- } else {
- std::vector <unsigned int> bkgd_top_color, bkgd_bottom_color;
- if(reader.get_vector("top_color", bkgd_top_color) &&
- reader.get_vector("bottom_color", bkgd_bottom_color))
- set_gradient(Color(bkgd_top_color), Color(bkgd_bottom_color));
+ // read position, defaults to (0,0)
+ float px = 0;
+ float py = 0;
+ reader.get("x", px);
+ reader.get("y", py);
+ this->pos = Vector(px,py);
+
+ speed = 1.0;
+ speed_y = 1.0;
+
+ std::string alignment_str;
+ if (reader.get("alignment", alignment_str))
+ {
+ if (alignment_str == "left")
+ {
+ alignment = LEFT_ALIGNMENT;
+ }
+ else if (alignment_str == "right")
+ {
+ alignment = RIGHT_ALIGNMENT;
+ }
+ else if (alignment_str == "top")
+ {
+ alignment = TOP_ALIGNMENT;
+ }
+ else if (alignment_str == "bottom")
+ {
+ alignment = BOTTOM_ALIGNMENT;
+ }
+ else if (alignment_str == "none")
+ {
+ alignment = NO_ALIGNMENT;
+ }
+ else
+ {
+ log_warning << "Background: invalid alignment: '" << alignment_str << "'" << std::endl;
+ alignment = NO_ALIGNMENT;
+ }
+ }
+
+ reader.get("scroll-offset-x", scroll_offset.x);
+ reader.get("scroll-offset-y", scroll_offset.y);
+
+ reader.get("scroll-speed-x", scroll_speed.x);
+ reader.get("scroll-speed-y", scroll_speed.y);
+
+ layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND0);
+
+ if(!reader.get("image", imagefile) || !reader.get("speed", speed))
+ throw std::runtime_error("Must specify image and speed for background");
+
+ set_image(imagefile, speed);
+ if (!reader.get("speed-y", speed_y))
+ {
+ speed_y = speed;
+ }
+
+ if (reader.get("image-top", imagefile_top)) {
+ image_top = Surface::create(imagefile_top);
+ }
+ if (reader.get("image-bottom", imagefile_bottom)) {
+ image_bottom = Surface::create(imagefile_bottom);