- added spotlight (not working, since rotation and blend modes are missing from Sprite)
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 3 Jul 2006 04:18:08 +0000 (04:18 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 3 Jul 2006 04:18:08 +0000 (04:18 +0000)
SVN-Revision: 3847

data/images/objects/spotlight/lightcone.png [new file with mode: 0644]
data/images/objects/spotlight/lightcone.sprite [new file with mode: 0644]
data/images/objects/spotlight/spotlight_base.png [new file with mode: 0644]
data/images/objects/spotlight/spotlight_base.sprite [new file with mode: 0644]
data/images/objects/spotlight/spotlight_center.png [new file with mode: 0644]
data/images/objects/spotlight/spotlight_center.sprite [new file with mode: 0644]
data/images/objects/spotlight/spotlight_lights.png [new file with mode: 0644]
data/images/objects/spotlight/spotlight_lights.sprite [new file with mode: 0644]
src/object/spotlight.cpp [new file with mode: 0644]
src/object/spotlight.hpp [new file with mode: 0644]

diff --git a/data/images/objects/spotlight/lightcone.png b/data/images/objects/spotlight/lightcone.png
new file mode 100644 (file)
index 0000000..6a7e89d
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 (file)
index 0000000..f38f208
--- /dev/null
@@ -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 (file)
index 0000000..08905a0
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 (file)
index 0000000..7901be0
--- /dev/null
@@ -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 (file)
index 0000000..affbd26
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 (file)
index 0000000..996fd44
--- /dev/null
@@ -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 (file)
index 0000000..a9e6371
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 (file)
index 0000000..3ba02bb
--- /dev/null
@@ -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 (file)
index 0000000..5778b9e
--- /dev/null
@@ -0,0 +1,70 @@
+//  $Id: light.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+//  SuperTux
+//  Copyright (C) 2006 Ingo Ruhnke <grumbel@gmx.de>
+//
+//  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 <config.h>
+
+#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 (file)
index 0000000..4948fb6
--- /dev/null
@@ -0,0 +1,45 @@
+//  $Id: light.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+//  SuperTux
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+//  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
+