- added spotlight (not working, since rotation and blend modes are missing from Sprite)
[supertux.git] / src / object / spotlight.cpp
1 //  $Id: light.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
2 //
3 //  SuperTux
4 //  Copyright (C) 2006 Ingo Ruhnke <grumbel@gmx.de>
5 //
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.
10 //
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.
15 //
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.
19
20 #include <config.h>
21
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"
27 #include "player.hpp"
28 #include "sector.hpp"
29
30 Spotlight::Spotlight(const lisp::Lisp& )
31 {
32   center    = sprite_manager->create("images/objects/spotlight/spotlight_center.sprite");
33   base      = sprite_manager->create("images/objects/spotlight/spotlight_base.sprite");
34   lights    = sprite_manager->create("images/objects/spotlight/spotlight_lights.sprite");
35   lightcone = sprite_manager->create("images/objects/spotlight/lightcone.sprite");
36 }
37
38 Spotlight::~Spotlight()
39 {
40   delete center;
41   delete base;
42   delete lights;
43   delete lightcone;
44 }
45
46 void
47 Spotlight::update(float )
48 {
49   // FIXME: add rotation code
50 }
51
52 void
53 Spotlight::draw(DrawingContext& context)
54 {
55   context.push_target();
56   context.set_target(DrawingContext::LIGHTMAP);
57  
58   Vector pos(100, 300);
59   lightcone->draw(context, pos, 0);
60   // rotate this one 180 degree
61   lightcone->draw(context, pos, 0);
62   
63   context.set_target(DrawingContext::NORMAL);
64   base->draw(context, pos, 0);
65   center->draw(context, pos, 0);
66
67   context.pop_target();
68 }
69
70 IMPLEMENT_FACTORY(Spotlight, "spotlight");