-// $Id: light.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
-//
// SuperTux
-// Copyright (C) 2006 Ingo Ruhnke <grumbel@gmx.de>
+// Copyright (C) 2006 Ingo Ruhnke <grumbel@gmail.com>
//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include <config.h>
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "spotlight.hpp"
+#include "object/spotlight.hpp"
+#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"
-#include "resources.hpp"
-#include "video/drawing_context.hpp"
-#include "object_factory.hpp"
-#include "player.hpp"
-#include "sector.hpp"
+#include "supertux/object_factory.hpp"
+#include "util/reader.hpp"
-Spotlight::Spotlight(const lisp::Lisp& lisp)
+Spotlight::Spotlight(const Reader& lisp) :
+ position(),
+ angle(0.0f),
+ center(),
+ base(),
+ lights(),
+ light(),
+ lightcone(),
+ color(1.0f, 1.0f, 1.0f)
{
lisp.get("x", position.x);
lisp.get("y", position.y);
-
- center = sprite_manager->create("images/objects/spotlight/spotlight_center.sprite");
- base = sprite_manager->create("images/objects/spotlight/spotlight_base.sprite");
- lights = sprite_manager->create("images/objects/spotlight/spotlight_lights.sprite");
- lightcone = sprite_manager->create("images/objects/spotlight/lightcone.sprite");
- light = sprite_manager->create("images/objects/spotlight/light.sprite");
-
- angle = 0.0f;
+
+ lisp.get("angle", angle);
+
+ std::vector<float> vColor;
+ if( lisp.get( "color", vColor ) ){
+ color = Color( vColor );
+ }
+
+ center = SpriteManager::current()->create("images/objects/spotlight/spotlight_center.sprite");
+ base = SpriteManager::current()->create("images/objects/spotlight/spotlight_base.sprite");
+ lights = SpriteManager::current()->create("images/objects/spotlight/spotlight_lights.sprite");
+ lightcone = SpriteManager::current()->create("images/objects/spotlight/lightcone.sprite");
+ light = SpriteManager::current()->create("images/objects/spotlight/light.sprite");
+
}
Spotlight::~Spotlight()
{
- delete center;
- delete base;
- delete lights;
- delete lightcone;
- delete light;
}
void
void
Spotlight::draw(DrawingContext& context)
{
- context.push_target();
+ context.push_target();
context.set_target(DrawingContext::LIGHTMAP);
-
+
+ light->set_color(color);
+ light->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
light->set_angle(angle);
light->draw(context, position, 0);
//lightcone->set_angle(angle);
//lightcone->draw(context, position, 0);
-
+
context.set_target(DrawingContext::NORMAL);
lights->set_angle(angle);
context.pop_target();
}
-IMPLEMENT_FACTORY(Spotlight, "spotlight");
+/* EOF */