2 // Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
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.
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.
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/>.
17 #include "object/torch.hpp"
19 #include "object/player.hpp"
20 #include "sprite/sprite.hpp"
21 #include "sprite/sprite_manager.hpp"
22 #include "util/reader.hpp"
24 Torch::Torch(const Reader& reader) :
31 reader.get("x", bbox.p1.x);
32 reader.get("y", bbox.p1.y);
34 std::string sprite_name = "images/objects/torch/torch1.sprite";
35 reader.get("sprite", sprite_name);
37 bbox.p2.x = bbox.p1.x + 50;
38 bbox.p2.y = bbox.p1.y + 50;
40 m_torch = SpriteManager::current()->create(sprite_name);
41 m_flame = SpriteManager::current()->create("images/objects/torch/flame.sprite");
42 m_flame_glow = SpriteManager::current()->create("images/objects/torch/flame_glow.sprite");
43 m_flame_glow->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
44 m_flame_light = SpriteManager::current()->create("images/objects/torch/flame_light.sprite");
45 m_flame_light->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
46 set_group(COLGROUP_TOUCHABLE);
50 Torch::draw(DrawingContext& context)
54 m_flame->draw(context, get_pos(), LAYER_TILES - 1);
56 context.push_target();
57 context.set_target(DrawingContext::LIGHTMAP);
58 m_flame_light->draw(context, get_pos(), 0);
62 m_torch->draw(context, get_pos(), LAYER_TILES - 1);
66 m_flame_glow->draw(context, get_pos(), LAYER_TILES - 1);
76 Torch::collision(GameObject& other, const CollisionHit& )
78 // FIXME: this doesn't work, as bbox is wrong
79 Player* player = dynamic_cast<Player*>(&other);