src/worldmap/special_tile.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 "sprite/sprite.hpp"
00020 #include "sprite/sprite_manager.hpp"
00021 #include "util/reader.hpp"
00022 #include "video/drawing_context.hpp"
00023 #include "worldmap/special_tile.hpp"
00024 
00025 namespace worldmap {
00026 
00027 SpecialTile::SpecialTile(const Reader& lisp) :
00028   pos(),
00029   sprite(),
00030   map_message(),
00031   passive_message(false), 
00032   script(),
00033   invisible(false),
00034   apply_action_north(true), 
00035   apply_action_east(true),
00036   apply_action_south(true), 
00037   apply_action_west(true)
00038 {
00039   lisp.get("x", pos.x);
00040   lisp.get("y", pos.y);
00041   lisp.get("invisible-tile", invisible);
00042 
00043   if(!invisible) {
00044     std::string spritefile = "";
00045     lisp.get("sprite", spritefile);
00046     sprite = sprite_manager->create(spritefile);
00047   }
00048 
00049   lisp.get("map-message", map_message);
00050   lisp.get("passive-message", passive_message);
00051   lisp.get("script", script);
00052 
00053   std::string apply_direction;
00054   lisp.get("apply-to-direction", apply_direction);
00055   if(!apply_direction.empty()) {
00056     apply_action_north = false;
00057     apply_action_south = false;
00058     apply_action_east = false;
00059     apply_action_west = false;
00060     if(apply_direction.find("north") != std::string::npos)
00061       apply_action_north = true;
00062     if(apply_direction.find("south") != std::string::npos)
00063       apply_action_south = true;
00064     if(apply_direction.find("east") != std::string::npos)
00065       apply_action_east = true;
00066     if(apply_direction.find("west") != std::string::npos)
00067       apply_action_west = true;
00068   }
00069 }
00070 
00071 SpecialTile::~SpecialTile()
00072 {
00073 }
00074 
00075 void
00076 SpecialTile::draw(DrawingContext& context)
00077 {
00078   if(invisible)
00079     return;
00080 
00081   sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
00082 }
00083 
00084 void
00085 SpecialTile::update(float )
00086 {
00087 }
00088 
00089 }
00090 
00091 /* EOF */

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