Enhanced Willowisp glow, added Kugelblitz glow
authorLMH <lmh.0013@gmail.com>
Tue, 9 Apr 2013 21:23:54 +0000 (11:23 -1000)
committerLMH <lmh.0013@gmail.com>
Tue, 9 Apr 2013 21:23:54 +0000 (11:23 -1000)
data/levels/test/glow_effects.stl
src/badguy/kugelblitz.cpp
src/badguy/kugelblitz.hpp
src/badguy/willowisp.cpp
src/badguy/willowisp.hpp

index 8b3e2c8..64667de 100755 (executable)
@@ -7,19 +7,23 @@
                (ambient-light  0.02    0.02    0.02    )                                                                                                                                                                                                                                                                                                       
                (camera (mode   "normal"        ))                                                                                                                                                                                                                                                                                                              
                (music   "music/voc-dark.ogg"   )                                                                                                                                                                                                                                                                                                                       
-                                                                                                                                                                                                                                                                                                                                                       
-               (spawnpoint     (name   "main"  )                                                                                                                                                                                                                                                                                                               
-                       (x      64      )(y     448     ))                                                                                                                                                                                                                                                                                              
-                                                                                                                                                                                                                                                                                                                                                       
+
+               (spawnpoint     (name   "main"  )
+                       (x      64      )(y     448     ))
+               (spawnpoint     (name   "top"   )
+                       (x      656     )(y     288     ))
+
+
                (mrbomb (x      832     )(y     736     ))                                                                                                                                                                                                                                                                                              
                (short_fuse     (x      1056    )(y     736     ))                                                                                                                                                                                                                                                                                              
                (short_fuse     (x      1152    )(y     736     ))                                                                                                                                                                                                                                                                                              
                (short_fuse     (x      1248    )(y     736     ))                                                                                                                                                                                                                                                                                              
                (haywire        (x      928     )(y     736     ))                                                                                                                                                                                                                                                                                              
-               (flame  (x      576     )(y     480     )(speed 0.2))                                                                                                                                                                                                                                                                                           
-               (iceflame       (x      736     )(y     480     )(speed 0.2))                                                                                                                                                                                                                                                                                           
-               (ghostflame     (x      656     )(y     160     ))                                                                                                                                                                                                                                                                                              
-                                                                                                                                                                                                                                                                                                                                                       
+               (flame  (x      576     )(y     480     )(speed 0.2))
+               (iceflame       (x      736     )(y     480     )(speed 0.2))
+               (ghostflame     (x      656     )(y     160     ))
+    (kugelblitz (x 48 )(y 576 ))
+
                (tilemap        (name   "Interactive"   )                                                                                                                                                                                                                                                                                                               
                        (z-pos  0       )(solid #t      )                                                                                                                                                                                                                                                                                               
                        (width  42      )(height        30      )                                                                                                                                                                                                                                                                                               
                (bonusblock     (x      608     )(y     352     )(contents      "star"  )(count 0       ))                                                                                                                                                                                                                                                              
                (bonusblock     (x      704     )(y     352     )(contents      "1up"   )(count 0       ))                                                                                                                                                                                                                                                              
                (bonusblock     (x      768     )(y     352     )(contents      "firegrow"      )(count 0       ))                                                                                                                                                                                                                                                              
-                                                                                                                                                                                                                                                                                                                                                       
+
+    (willowisp (x 48 )(y 544)(spawnpoint "top" ))
+    (willowisp (x 1232 )(y 544)(spawnpoint "top" ))
 ))                                                                                                                                                                                                                                                                                                                                                     
index 6b6e81e..c1c7742 100644 (file)
@@ -22,6 +22,7 @@
 #include "object/camera.hpp"
 #include "object/player.hpp"
 #include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
 #include "supertux/object_factory.hpp"
 #include "supertux/sector.hpp"
 #include "util/reader.hpp"
@@ -39,12 +40,17 @@ Kugelblitz::Kugelblitz(const Reader& reader) :
   movement_timer(),
   lifetime(),
   direction(),
-  state()
+  state(),
+  light(0.0f,0.0f,0.0f),
+  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite"))
 {
   reader.get("x", start_position.x);
   sprite->set_action("falling");
   physic.enable_gravity(false);
   countMe = false;
+  
+  lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+  lightsprite->set_color(Color(0.2f, 0.1f, 0.0f));  
 }
 
 void
@@ -150,6 +156,22 @@ Kugelblitz::active_update(float elapsed_time)
 }
 
 void
+Kugelblitz::draw(DrawingContext& context)
+{
+  sprite->draw(context, get_pos(), layer);
+  
+  //Only draw light in dark areas
+  context.get_light( get_bbox().get_middle(), &light );
+  if (light.red + light.green < 2.0){
+    context.push_target();
+    context.set_target(DrawingContext::LIGHTMAP);
+    sprite->draw(context, get_pos(), layer);
+    lightsprite->draw(context, get_bbox().get_middle(), 0);
+    context.pop_target();
+  }
+}
+
+void
 Kugelblitz::kill_fall()
 {
 }
index 32c479d..95d402c 100644 (file)
@@ -32,6 +32,8 @@ public:
   void active_update(float);
   void kill_fall();
   void explode();
+  
+  virtual void draw(DrawingContext& context);
 
 private:
   void try_activate();
@@ -45,6 +47,8 @@ private:
   Timer lifetime;
   int direction;
   State state;
+  Color light;
+  SpritePtr lightsprite;
 };
 
 #endif
index 7fb4082..8e582a9 100644 (file)
@@ -23,6 +23,7 @@
 #include "object/player.hpp"
 #include "scripting/squirrel_util.hpp"
 #include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
 #include "supertux/game_session.hpp"
 #include "supertux/object_factory.hpp"
 #include "supertux/sector.hpp"
@@ -44,7 +45,8 @@ WillOWisp::WillOWisp(const Reader& reader) :
   walker(),
   flyspeed(),
   track_range(),
-  vanish_range()
+  vanish_range(),
+  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   bool running = false;
   flyspeed     = FLYSPEED;
@@ -73,6 +75,9 @@ WillOWisp::WillOWisp(const Reader& reader) :
   sound_manager->preload(SOUNDFILE);
   sound_manager->preload("sounds/warp.wav");
 
+  lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+  lightsprite->set_color(Color(0.0f, 0.2f, 0.0f));
+
   sprite->set_action("idle");
 }
 
@@ -85,6 +90,7 @@ WillOWisp::draw(DrawingContext& context)
   context.set_target(DrawingContext::LIGHTMAP);
 
   sprite->draw(context, get_pos(), layer);
+  lightsprite->draw(context, get_bbox().get_middle(), 0);
 
   context.pop_target();
 }
index 19e4bb1..42ad8fc 100644 (file)
@@ -81,6 +81,7 @@ private:
   float flyspeed;
   float track_range;
   float vanish_range;
+  SpritePtr lightsprite;
 };
 
 #endif