ea2bd203284618ad2cabdb56371cd250bf439c4e
[supertux.git] / src / worldmap / special_tile.cpp
1 //  $Id$
2 //
3 //  SuperTux
4 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
5 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; either version 2
10 //  of the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 #include <config.h>
21
22 #include "worldmap/special_tile.hpp"
23 #include "sprite/sprite_manager.hpp"
24 #include "sprite/sprite.hpp"
25 #include "video/drawing_context.hpp"
26
27 namespace WorldMapNS
28 {
29
30 SpecialTile::SpecialTile(const lisp::Lisp* lisp)
31   : passive_message(false), invisible(false),
32     apply_action_north(true), apply_action_east(true),
33     apply_action_south(true), apply_action_west(true)
34 {
35   lisp->get("x", pos.x);
36   lisp->get("y", pos.y);
37   lisp->get("invisible-tile", invisible);
38   
39   if(!invisible) {
40     std::string spritefile = "";
41     lisp->get("sprite", spritefile);
42     sprite.reset(sprite_manager->create(spritefile));
43   }
44
45   lisp->get("map-message", map_message);
46   lisp->get("passive-message", passive_message);
47   lisp->get("script", script);
48
49   std::string apply_direction;
50   lisp->get("apply-to-direction", apply_direction);
51   if(!apply_direction.empty()) {
52     apply_action_north = false;
53     apply_action_south = false;
54     apply_action_east = false;
55     apply_action_west = false;
56     if(apply_direction.find("north") != std::string::npos)
57       apply_action_north = true;
58     if(apply_direction.find("south") != std::string::npos)
59       apply_action_south = true;
60     if(apply_direction.find("east") != std::string::npos)
61       apply_action_east = true;
62     if(apply_direction.find("west") != std::string::npos)
63       apply_action_west = true;
64   }
65 }
66
67 SpecialTile::~SpecialTile()
68 {
69 }
70
71 void
72 SpecialTile::draw(DrawingContext& context)
73 {
74   if(invisible)
75     return;
76
77   sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
78 }
79
80 void
81 SpecialTile::update(float )
82 {
83 }
84
85 }
86