X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fbackground.cpp;h=619645b63cade6522c698492c123511ab44772cc;hb=78ac7aef674f518549f96160c6354b589553f952;hp=f42de1acafcd50053c3333f3761dba7ca55cf5c1;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/object/background.cpp b/src/object/background.cpp index f42de1aca..619645b63 100644 --- a/src/object/background.cpp +++ b/src/object/background.cpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,29 +12,38 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include +// along with this program. If not, see . -#include -#include "background.hpp" -#include "camera.hpp" -#include "video/drawing_context.hpp" -#include "lisp/lisp.hpp" -#include "lisp/writer.hpp" -#include "object_factory.hpp" -#include "resources.hpp" -#include "main.hpp" -#include "log.hpp" +#include "object/background.hpp" +#include "supertux/globals.hpp" +#include "supertux/object_factory.hpp" +#include "util/reader.hpp" -Background::Background() - : layer(LAYER_BACKGROUND0) +Background::Background() : + layer(LAYER_BACKGROUND0), + imagefile_top(), + imagefile(), + imagefile_bottom(), + pos(), + speed(), + speed_y(), + image_top(), + image(), + image_bottom() { } -Background::Background(const lisp::Lisp& reader) - : layer(LAYER_BACKGROUND0) +Background::Background(const Reader& reader) : + layer(LAYER_BACKGROUND0), + imagefile_top(), + imagefile(), + imagefile_bottom(), + pos(), + speed(), + speed_y(), + image_top(), + image(), + image_bottom() { // read position, defaults to (0,0) float px = 0; @@ -51,7 +58,7 @@ Background::Background(const lisp::Lisp& reader) reader.get("layer", layer); if(!reader.get("image", imagefile) || !reader.get("speed", speed)) throw std::runtime_error("Must specify image and speed for background"); - + set_image(imagefile, speed); reader.get("speed-y", speed_y); if (reader.get("image-top", imagefile_top)) { @@ -67,25 +74,6 @@ Background::~Background() } void -Background::write(lisp::Writer& writer) -{ - writer.start_list("background"); - - if (image_top.get() != NULL) - writer.write_string("image-top", imagefile_top); - - writer.write_string("image", imagefile); - if (image_bottom.get() != NULL) - writer.write_string("image-bottom", imagefile_bottom); - - writer.write_float("speed", speed); - writer.write_float("speed-y", speed_y); - writer.write_int("layer", layer); - - writer.end_list("background"); -} - -void Background::update(float) { } @@ -104,7 +92,7 @@ Background::draw(DrawingContext& context) { if(image.get() == NULL) return; - + int w = (int) image->get_width(); int h = (int) image->get_height(); int sx = int(pos.x-context.get_translation().x * speed) % w - w; @@ -118,7 +106,7 @@ Background::draw(DrawingContext& context) if (image_top.get() != NULL && (y < center_image_py)) { context.draw_surface(image_top.get(), Vector(x, y), layer); continue; - } + } if (image_bottom.get() != NULL && (y >= bottom_image_py)) { context.draw_surface(image_bottom.get(), Vector(x, y), layer); continue; @@ -130,3 +118,5 @@ Background::draw(DrawingContext& context) } IMPLEMENT_FACTORY(Background, "background"); + +/* EOF */