Fixed draw range in Background
authorgrumbel <grumbel@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Tue, 1 Dec 2009 04:21:09 +0000 (04:21 +0000)
committergrumbel <grumbel@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Tue, 1 Dec 2009 04:21:09 +0000 (04:21 +0000)
git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6162 837edb03-e0f3-0310-88ca-d4d4e8b29345

src/object/background.cpp

index 728adc7..0ed917b 100644 (file)
@@ -85,6 +85,10 @@ Background::Background(const Reader& reader) :
     {
       alignment = BOTTOM_ALIGNMENT;
     }
+    else if (alignment_str == "none")
+    {
+      alignment = NO_ALIGNMENT;
+    }
     else
     {
       log_warning << "Background: invalid alignment: '" << alignment_str << "'" << std::endl;
@@ -143,10 +147,10 @@ Background::draw_image(DrawingContext& context, const Vector& pos)
   Sizef parallax_image_size = (1.0f - speed) * screen + level * speed;
 
   // FIXME: Implement proper clipping here
-  int start_x = -level.width  / image->get_width()  / 2;
-  int end_x   =  level.width  / image->get_width()  / 2;
-  int start_y = -level.height / image->get_height() / 2;
-  int end_y   =  level.height / image->get_height() / 2;
+  int start_x = -parallax_image_size.width  / 2.0f / image->get_width()  - 1;
+  int end_x   =  parallax_image_size.width  / 2.0f / image->get_width()  + 1;
+  int start_y = -parallax_image_size.height / 2.0f / image->get_height() - 1;
+  int end_y   =  parallax_image_size.height / 2.0f / image->get_height() + 1;
 
   switch(alignment)
   {