From: Ingo Ruhnke Date: Mon, 3 Jul 2006 04:18:08 +0000 (+0000) Subject: - added spotlight (not working, since rotation and blend modes are missing from Sprite) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=20a94a721fdee25587d1698ff8cfd6d014b590f1;p=supertux.git - added spotlight (not working, since rotation and blend modes are missing from Sprite) SVN-Revision: 3847 --- diff --git a/data/images/objects/spotlight/lightcone.png b/data/images/objects/spotlight/lightcone.png new file mode 100644 index 000000000..6a7e89d52 Binary files /dev/null and b/data/images/objects/spotlight/lightcone.png differ diff --git a/data/images/objects/spotlight/lightcone.sprite b/data/images/objects/spotlight/lightcone.sprite new file mode 100644 index 000000000..f38f20867 --- /dev/null +++ b/data/images/objects/spotlight/lightcone.sprite @@ -0,0 +1,6 @@ +(supertux-sprite + (action + (name "default") + (images "lightcone.png") + ) +) diff --git a/data/images/objects/spotlight/spotlight_base.png b/data/images/objects/spotlight/spotlight_base.png new file mode 100644 index 000000000..08905a019 Binary files /dev/null and b/data/images/objects/spotlight/spotlight_base.png differ diff --git a/data/images/objects/spotlight/spotlight_base.sprite b/data/images/objects/spotlight/spotlight_base.sprite new file mode 100644 index 000000000..7901be0e2 --- /dev/null +++ b/data/images/objects/spotlight/spotlight_base.sprite @@ -0,0 +1,6 @@ +(supertux-sprite + (action + (name "default") + (images "spotlight_base.png") + ) +) diff --git a/data/images/objects/spotlight/spotlight_center.png b/data/images/objects/spotlight/spotlight_center.png new file mode 100644 index 000000000..affbd265a Binary files /dev/null and b/data/images/objects/spotlight/spotlight_center.png differ diff --git a/data/images/objects/spotlight/spotlight_center.sprite b/data/images/objects/spotlight/spotlight_center.sprite new file mode 100644 index 000000000..996fd4446 --- /dev/null +++ b/data/images/objects/spotlight/spotlight_center.sprite @@ -0,0 +1,6 @@ +(supertux-sprite + (action + (name "default") + (images "spotlight_center.png") + ) +) diff --git a/data/images/objects/spotlight/spotlight_lights.png b/data/images/objects/spotlight/spotlight_lights.png new file mode 100644 index 000000000..a9e63710b Binary files /dev/null and b/data/images/objects/spotlight/spotlight_lights.png differ diff --git a/data/images/objects/spotlight/spotlight_lights.sprite b/data/images/objects/spotlight/spotlight_lights.sprite new file mode 100644 index 000000000..3ba02bbd8 --- /dev/null +++ b/data/images/objects/spotlight/spotlight_lights.sprite @@ -0,0 +1,6 @@ +(supertux-sprite + (action + (name "default") + (images "spotlight_lights.png") + ) +) diff --git a/src/object/spotlight.cpp b/src/object/spotlight.cpp new file mode 100644 index 000000000..5778b9e94 --- /dev/null +++ b/src/object/spotlight.cpp @@ -0,0 +1,70 @@ +// $Id: light.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $ +// +// SuperTux +// Copyright (C) 2006 Ingo Ruhnke +// +// 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 distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// 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 + +#include "spotlight.hpp" +#include "sprite/sprite_manager.hpp" +#include "resources.hpp" +#include "video/drawing_context.hpp" +#include "object_factory.hpp" +#include "player.hpp" +#include "sector.hpp" + +Spotlight::Spotlight(const lisp::Lisp& ) +{ + 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"); +} + +Spotlight::~Spotlight() +{ + delete center; + delete base; + delete lights; + delete lightcone; +} + +void +Spotlight::update(float ) +{ + // FIXME: add rotation code +} + +void +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); + + context.set_target(DrawingContext::NORMAL); + base->draw(context, pos, 0); + center->draw(context, pos, 0); + + context.pop_target(); +} + +IMPLEMENT_FACTORY(Spotlight, "spotlight"); diff --git a/src/object/spotlight.hpp b/src/object/spotlight.hpp new file mode 100644 index 000000000..4948fb674 --- /dev/null +++ b/src/object/spotlight.hpp @@ -0,0 +1,45 @@ +// $Id: light.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $ +// +// SuperTux +// Copyright (C) 2006 Matthias Braun +// +// 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 distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// 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. + +#ifndef __SPOTLIGHT_HPP__ +#define __SPOTLIGHT_HPP__ + +#include "game_object.hpp" +#include "lisp/lisp.hpp" + +class Sprite; + +class Spotlight : public GameObject +{ +public: + Spotlight(const lisp::Lisp& reader); + virtual ~Spotlight(); + + void update(float elapsed_time); + void draw(DrawingContext& context); + +private: + Sprite* center; + Sprite* base; + Sprite* lights; + Sprite* lightcone; +}; + +#endif +