Skip to content

Commit

Permalink
Enhanced Willowisp glow, added Kugelblitz glow
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH0013 committed Apr 9, 2013
1 parent 0dfd364 commit 79dacf6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 11 deletions.
24 changes: 15 additions & 9 deletions data/levels/test/glow_effects.stl
Expand Up @@ -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 )
Expand Down Expand Up @@ -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" ))
))
24 changes: 23 additions & 1 deletion src/badguy/kugelblitz.cpp
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -149,6 +155,22 @@ Kugelblitz::active_update(float elapsed_time)
BadGuy::active_update(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()
{
Expand Down
4 changes: 4 additions & 0 deletions src/badguy/kugelblitz.hpp
Expand Up @@ -32,6 +32,8 @@ class Kugelblitz : public BadGuy
void active_update(float);
void kill_fall();
void explode();

virtual void draw(DrawingContext& context);

private:
void try_activate();
Expand All @@ -45,6 +47,8 @@ class Kugelblitz : public BadGuy
Timer lifetime;
int direction;
State state;
Color light;
SpritePtr lightsprite;
};

#endif
Expand Down
8 changes: 7 additions & 1 deletion src/badguy/willowisp.cpp
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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");
}

Expand All @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions src/badguy/willowisp.hpp
Expand Up @@ -81,6 +81,7 @@ class WillOWisp : public BadGuy,
float flyspeed;
float track_range;
float vanish_range;
SpritePtr lightsprite;
};

#endif
Expand Down

0 comments on commit 79dacf6

Please sign in to comment.