From: LMH Date: Tue, 9 Apr 2013 21:23:54 +0000 (-1000) Subject: Enhanced Willowisp glow, added Kugelblitz glow X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=79dacf66079bc6c0817d947c4ae922c8d4f75575;p=supertux.git Enhanced Willowisp glow, added Kugelblitz glow --- diff --git a/data/levels/test/glow_effects.stl b/data/levels/test/glow_effects.stl index 8b3e2c86d..64667de24 100755 --- a/data/levels/test/glow_effects.stl +++ b/data/levels/test/glow_effects.stl @@ -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 ) @@ -96,5 +100,7 @@ (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" )) )) diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index 6b6e81e1c..c1c774270 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -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() { } diff --git a/src/badguy/kugelblitz.hpp b/src/badguy/kugelblitz.hpp index 32c479df7..95d402c9b 100644 --- a/src/badguy/kugelblitz.hpp +++ b/src/badguy/kugelblitz.hpp @@ -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 diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 7fb4082ad..8e582a90e 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -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(); } diff --git a/src/badguy/willowisp.hpp b/src/badguy/willowisp.hpp index 19e4bb133..42ad8fc70 100644 --- a/src/badguy/willowisp.hpp +++ b/src/badguy/willowisp.hpp @@ -81,6 +81,7 @@ private: float flyspeed; float track_range; float vanish_range; + SpritePtr lightsprite; }; #endif