- some small adjustments to the lighting
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 3 Jul 2006 18:21:05 +0000 (18:21 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 3 Jul 2006 18:21:05 +0000 (18:21 +0000)
SVN-Revision: 3855

data/images/objects/spotlight/light.png [new file with mode: 0644]
data/images/objects/spotlight/light.sprite [new file with mode: 0644]
data/images/objects/spotlight/lightcone.png
data/levels/test/light.stl
src/object/spotlight.cpp
src/object/spotlight.hpp
src/video/drawing_context.cpp

diff --git a/data/images/objects/spotlight/light.png b/data/images/objects/spotlight/light.png
new file mode 100644 (file)
index 0000000..16f33ac
Binary files /dev/null and b/data/images/objects/spotlight/light.png differ
diff --git a/data/images/objects/spotlight/light.sprite b/data/images/objects/spotlight/light.sprite
new file mode 100644 (file)
index 0000000..2af97de
--- /dev/null
@@ -0,0 +1,7 @@
+(supertux-sprite
+    (action
+      (name "default")
+      (images "light.png")
+      (hitbox 500 500 0 0)
+    )
+)
index 63393e8..b2ae01d 100644 (file)
Binary files a/data/images/objects/spotlight/lightcone.png and b/data/images/objects/spotlight/lightcone.png differ
index 77473f1..f41d431 100644 (file)
@@ -70,6 +70,7 @@
 (reset-points
 )
 (objects
-  (spotlight )
+  (spotlight (x 100) (y 300))
+  (spotlight (x 500) (y 200))
 )
 )
index e15cdf3..d171525 100644 (file)
 #include "player.hpp"
 #include "sector.hpp"
 
-Spotlight::Spotlight(const lisp::Lisp& )
+Spotlight::Spotlight(const lisp::Lisp& lisp)
 {
+  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;
 }
@@ -43,6 +47,7 @@ Spotlight::~Spotlight()
   delete base;
   delete lights;
   delete lightcone;
+  delete light;
 }
 
 void
@@ -57,23 +62,24 @@ Spotlight::draw(DrawingContext& context)
   context.push_target(); 
   context.set_target(DrawingContext::LIGHTMAP);
  
-  Vector pos(100, 300);
-
-  lightcone->set_angle(angle);
-  lightcone->draw(context, pos, 0);
+  light->set_angle(angle);
+  light->draw(context, position, 0);
 
-  lightcone->set_angle(angle + 180.0f);
-  lightcone->draw(context, pos, 0);
+  //lightcone->set_angle(angle);
+  //lightcone->draw(context, position, 0);
   
   context.set_target(DrawingContext::NORMAL);
 
   lights->set_angle(angle);
-  lights->draw(context, pos, 0);
+  lights->draw(context, position, 0);
 
   base->set_angle(angle);
-  base->draw(context, pos, 0);
+  base->draw(context, position, 0);
 
-  center->draw(context, pos, 0);
+  center->draw(context, position, 0);
+
+  lightcone->set_angle(angle);
+  lightcone->draw(context, position, LAYER_FOREGROUND1 + 10);
 
   context.pop_target();
 }
index 520ad1a..e8d76e1 100644 (file)
@@ -21,6 +21,7 @@
 #define __SPOTLIGHT_HPP__
 
 #include "game_object.hpp"
+#include "math/vector.hpp"
 #include "lisp/lisp.hpp"
 
 class Sprite;
@@ -35,10 +36,12 @@ public:
   void draw(DrawingContext& context);
 
 private:
+  Vector  position;
   float   angle;
   Sprite* center;
   Sprite* base;
   Sprite* lights;
+  Sprite* light;
   Sprite* lightcone;
 };
 
index 5dbad18..281f981 100644 (file)
@@ -327,7 +327,7 @@ DrawingContext::do_drawing()
     glLoadIdentity();
 
     // FIXME: Add ambient light support here
-    glClearColor(0.5, 0.5, 0.5, 1);
+    glClearColor(0.3, 0.3, 0.4, 1);
     glClear(GL_COLOR_BUFFER_BIT);
     handle_drawing_requests(lightmap_requests);
     lightmap_requests.clear();