1 | // SuperTux - Teleporter Worldmap Tile |
2 | // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de> |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | |
17 | #include "worldmap/teleporter.hpp" |
18 | |
19 | #include "sprite/sprite.hpp" |
20 | #include "sprite/sprite_manager.hpp" |
21 | #include "util/reader_mapping.hpp" |
22 | |
23 | namespace worldmap { |
24 | |
25 | Teleporter::Teleporter(const ReaderMapping& mapping) : |
26 | m_pos(), |
27 | m_sprite(), |
28 | m_worldmap(), |
29 | m_spawnpoint(), |
30 | m_automatic(false), |
31 | m_message() |
32 | { |
33 | mapping.get("x" , m_pos.x); |
34 | mapping.get("y" , m_pos.y); |
35 | |
36 | std::string spritefile = "" ; |
37 | if (mapping.get("sprite" , spritefile)) { |
38 | m_sprite = SpriteManager::current()->create(spritefile); |
39 | } |
40 | |
41 | if (!mapping.get("worldmap" , m_worldmap)) { |
42 | // worldmap parameter doesn't need to be set. Ignore. |
43 | } |
44 | if (!mapping.get("spawnpoint" , m_spawnpoint)) { |
45 | // not set, use "main" spawnpoint. |
46 | } |
47 | if (!mapping.get("automatic" , m_automatic)) { |
48 | // doesn't need to be set. Don't teleport automatically. |
49 | } |
50 | if (!mapping.get("message" , m_message)) { |
51 | // Optional message not set. Ignore! |
52 | } |
53 | } |
54 | |
55 | void |
56 | Teleporter::draw(DrawingContext& context) |
57 | { |
58 | if (m_sprite) { |
59 | m_sprite->draw(context.color(), m_pos * 32 + Vector(16, 16), LAYER_OBJECTS - 1); |
60 | } |
61 | } |
62 | |
63 | void |
64 | Teleporter::update(float ) |
65 | { |
66 | } |
67 | |
68 | } // namespace worldmap |
69 | |
70 | /* EOF */ |
71 | |