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