X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fspotlight.cpp;h=d86848cf42854cd370e34babaa91741cfdc3e6f6;hb=a98f7cee9f6a2593c0e1f3442800f159bad410df;hp=5778b9e94deecbf6f7fab4122e7330c8a38acfdd;hpb=20a94a721fdee25587d1698ff8cfd6d014b590f1;p=supertux.git diff --git a/src/object/spotlight.cpp b/src/object/spotlight.cpp index 5778b9e94..d86848cf4 100644 --- a/src/object/spotlight.cpp +++ b/src/object/spotlight.cpp @@ -1,4 +1,4 @@ -// $Id: light.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $ +// $Id$ // // SuperTux // Copyright (C) 2006 Ingo Ruhnke @@ -27,12 +27,27 @@ #include "player.hpp" #include "sector.hpp" -Spotlight::Spotlight(const lisp::Lisp& ) +Spotlight::Spotlight(const lisp::Lisp& lisp) + : angle(0.0f), + color(1.0f, 1.0f, 1.0f) { + lisp.get("x", position.x); + lisp.get("y", position.y); + + lisp.get("angle", angle); + + std::vector vColor; + if( lisp.get_vector( "color", vColor ) ){ + color = Color( vColor ); + } + 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"); + + } Spotlight::~Spotlight() @@ -41,12 +56,13 @@ Spotlight::~Spotlight() delete base; delete lights; delete lightcone; + delete light; } void -Spotlight::update(float ) +Spotlight::update(float delta) { - // FIXME: add rotation code + angle += delta * 50.0f; } void @@ -54,15 +70,27 @@ Spotlight::draw(DrawingContext& context) { context.push_target(); context.set_target(DrawingContext::LIGHTMAP); - - Vector pos(100, 300); - lightcone->draw(context, pos, 0); - // rotate this one 180 degree - lightcone->draw(context, pos, 0); - + + 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); - base->draw(context, pos, 0); - center->draw(context, pos, 0); + + lights->set_angle(angle); + lights->draw(context, position, 0); + + base->set_angle(angle); + base->draw(context, position, 0); + + center->draw(context, position, 0); + + lightcone->set_angle(angle); + lightcone->draw(context, position, LAYER_FOREGROUND1 + 10); context.pop_target(); }