From: Matthias Braun Date: Tue, 23 Nov 2004 14:32:19 +0000 (+0000) Subject: make it possible to put background images in each layer X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2dcdb5c4759e73d6961770fed7250a939be3063f;p=supertux.git make it possible to put background images in each layer SVN-Revision: 2146 --- diff --git a/src/background.cpp b/src/background.cpp index 87ce973ad..5785df3d9 100644 --- a/src/background.cpp +++ b/src/background.cpp @@ -26,12 +26,12 @@ #include "utils/lispwriter.h" Background::Background() - : type(INVALID), image(0) + : type(INVALID), layer(LAYER_BACKGROUND0), image(0) { } Background::Background(LispReader& reader) - : type(INVALID), image(0) + : type(INVALID), layer(LAYER_BACKGROUND0), image(0) { if(reader.read_string("image", imagefile) && reader.read_float("speed", speed)) { @@ -71,6 +71,7 @@ Background::write(LispWriter& writer) writer.write_int_vector("top_color", bkgd_top_color); writer.write_int_vector("bottom_color", bkgd_bottom_color); } + writer.write_int("layer", layer); writer.end_list("background"); } @@ -109,12 +110,12 @@ Background::draw(DrawingContext& context) /* In case we are using OpenGL just draw the gradient, else (software mode) use the cache. */ if(use_gl) - context.draw_gradient(gradient_top, gradient_bottom, LAYER_BACKGROUND0); + context.draw_gradient(gradient_top, gradient_bottom, layer); else { context.push_transform(); context.set_translation(Vector(0, 0)); - context.draw_surface(image, Vector(0, 0), LAYER_BACKGROUND0); + context.draw_surface(image, Vector(0, 0), layer); context.pop_transform(); } } else if(type == IMAGE) { @@ -127,7 +128,7 @@ Background::draw(DrawingContext& context) context.set_translation(Vector(0, 0)); for(int x = sx; x < screen->w; x += image->w) for(int y = sy; y < screen->h; y += image->h) - context.draw_surface(image, Vector(x, y), LAYER_BACKGROUND0); + context.draw_surface(image, Vector(x, y), layer); context.pop_transform(); } } diff --git a/src/background.h b/src/background.h index 375343fca..7ed3e837c 100644 --- a/src/background.h +++ b/src/background.h @@ -60,6 +60,7 @@ private: }; Type type; + int layer; std::string imagefile; float speed; Surface* image; diff --git a/src/object/block.cpp b/src/object/block.cpp index ba794744b..340488313 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -47,7 +47,6 @@ Block::collision(GameObject& other, const CollisionHit& hitdata) // collided from below? if(hitdata.normal.x == 0 && hitdata.normal.y < 0 && player->get_movement().y < 0) { - printf("hit.\n"); hit(*player); }