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 color(1.0f, 1.0f, 1.0f)
34 lisp.get("x", position.x);
35 lisp.get("y", position.y);
37 lisp.get("angle", angle);
39 std::vector<float> vColor;
40 if( lisp.get_vector( "color", vColor ) ){
41 color = Color( vColor );
44 center = sprite_manager->create("images/objects/spotlight/spotlight_center.sprite");
45 base = sprite_manager->create("images/objects/spotlight/spotlight_base.sprite");
46 lights = sprite_manager->create("images/objects/spotlight/spotlight_lights.sprite");
47 lightcone = sprite_manager->create("images/objects/spotlight/lightcone.sprite");
48 light = sprite_manager->create("images/objects/spotlight/light.sprite");
53 Spotlight::~Spotlight()
63 Spotlight::update(float delta)
65 angle += delta * 50.0f;
69 Spotlight::draw(DrawingContext& context)
71 context.push_target();
72 context.set_target(DrawingContext::LIGHTMAP);
74 light->set_color(color);
75 light->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
76 light->set_angle(angle);
77 light->draw(context, position, 0);
79 //lightcone->set_angle(angle);
80 //lightcone->draw(context, position, 0);
82 context.set_target(DrawingContext::NORMAL);
84 lights->set_angle(angle);
85 lights->draw(context, position, 0);
87 base->set_angle(angle);
88 base->draw(context, position, 0);
90 center->draw(context, position, 0);
92 lightcone->set_angle(angle);
93 lightcone->draw(context, position, LAYER_FOREGROUND1 + 10);
98 IMPLEMENT_FACTORY(Spotlight, "spotlight");