src/worldmap/level.cpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
00003 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
00004 //
00005 //  This program is free software: you can redistribute it and/or modify
00006 //  it under the terms of the GNU General Public License as published by
00007 //  the Free Software Foundation, either version 3 of the License, or
00008 //  (at your option) any later version.
00009 //
00010 //  This program is distributed in the hope that it will be useful,
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 //  GNU General Public License for more details.
00014 //
00015 //  You should have received a copy of the GNU General Public License
00016 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 #include <config.h>
00018 
00019 #include <physfs.h>
00020 #include <stddef.h>
00021 
00022 #include "sprite/sprite.hpp"
00023 #include "sprite/sprite_manager.hpp"
00024 #include "util/file_system.hpp"
00025 #include "util/log.hpp"
00026 #include "util/reader.hpp"
00027 #include "video/drawing_context.hpp"
00028 #include "worldmap/level.hpp"
00029 
00030 namespace worldmap {
00031 
00032 LevelTile::LevelTile(const std::string& basedir, const Reader& lisp) :
00033   pos(),
00034   title(),
00035   solved(false), 
00036   auto_play(false), 
00037   sprite(),
00038   statistics(),
00039   extro_script(),
00040   basedir(basedir), 
00041   picture_cached(false),
00042   picture(0)
00043 {
00044   lisp.get("name", name);
00045   lisp.get("x", pos.x);
00046   lisp.get("y", pos.y);
00047   lisp.get("auto-play", auto_play);
00048 
00049   std::string spritefile = "images/worldmap/common/leveldot.sprite";
00050   lisp.get("sprite", spritefile);
00051   sprite = sprite_manager->create(spritefile);
00052 
00053   lisp.get("extro-script", extro_script);
00054 
00055   if (!PHYSFS_exists((basedir + name).c_str()))
00056   {
00057     log_warning << "level file '" << name
00058                 << "' does not exist and will not be added to the worldmap" << std::endl;
00059     return;
00060   }
00061 }
00062 
00063 LevelTile::~LevelTile()
00064 {
00065   delete picture;
00066 }
00067 
00068 void
00069 LevelTile::draw(DrawingContext& context)
00070 {
00071   sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
00072 }
00073 
00074 void
00075 LevelTile::update(float )
00076 {
00077 }
00078 
00079 } // namespace worldmap
00080 
00081 /* EOF */

Generated on Mon Jun 9 03:38:21 2014 for SuperTux by  doxygen 1.5.1