1 // $Id: light.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
4 // Copyright (C) 2006 Ingo Ruhnke <grumbel@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include "spotlight.hpp"
23 #include "sprite/sprite_manager.hpp"
24 #include "resources.hpp"
25 #include "video/drawing_context.hpp"
26 #include "object_factory.hpp"
30 Spotlight::Spotlight(const lisp::Lisp& lisp)
32 lisp.get("x", position.x);
33 lisp.get("y", position.y);
35 center = sprite_manager->create("images/objects/spotlight/spotlight_center.sprite");
36 base = sprite_manager->create("images/objects/spotlight/spotlight_base.sprite");
37 lights = sprite_manager->create("images/objects/spotlight/spotlight_lights.sprite");
38 lightcone = sprite_manager->create("images/objects/spotlight/lightcone.sprite");
39 light = sprite_manager->create("images/objects/spotlight/light.sprite");
44 Spotlight::~Spotlight()
54 Spotlight::update(float delta)
56 angle += delta * 50.0f;
60 Spotlight::draw(DrawingContext& context)
62 context.push_target();
63 context.set_target(DrawingContext::LIGHTMAP);
65 light->set_angle(angle);
66 light->draw(context, position, 0);
68 //lightcone->set_angle(angle);
69 //lightcone->draw(context, position, 0);
71 context.set_target(DrawingContext::NORMAL);
73 lights->set_angle(angle);
74 lights->draw(context, position, 0);
76 base->set_angle(angle);
77 base->draw(context, position, 0);
79 center->draw(context, position, 0);
81 lightcone->set_angle(angle);
82 lightcone->draw(context, position, LAYER_FOREGROUND1 + 10);
87 IMPLEMENT_FACTORY(Spotlight, "spotlight");