From: LMH Date: Thu, 1 Mar 2012 07:26:53 +0000 (-1000) Subject: Fireballs glow in the dark, and added basic torch sprite of bug 883 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=550dce76ed738792b13f80315913b39af7b723f6;p=supertux.git Fireballs glow in the dark, and added basic torch sprite of bug 883 --- diff --git a/data/images/objects/candle/candle-light.xcf b/data/images/objects/candle/candle-light.xcf new file mode 100644 index 000000000..1ab8fb5f6 Binary files /dev/null and b/data/images/objects/candle/candle-light.xcf differ diff --git a/data/images/objects/candle/torch/torch-off.png b/data/images/objects/candle/torch/torch-off.png new file mode 100644 index 000000000..b83dc5166 Binary files /dev/null and b/data/images/objects/candle/torch/torch-off.png differ diff --git a/data/images/objects/candle/torch/torch.sprite b/data/images/objects/candle/torch/torch.sprite new file mode 100644 index 000000000..d86176fb6 --- /dev/null +++ b/data/images/objects/candle/torch/torch.sprite @@ -0,0 +1,18 @@ +(supertux-sprite + (action + (name "on") + (images + "torch1.png" + "torch2.png" + "torch3.png" + ) + ) + (action + (name "off") + (hitbox 0 -32 32 32) + (images + "torch-off.png" + ) + ) + ) + diff --git a/data/images/objects/candle/torch/torch1.png b/data/images/objects/candle/torch/torch1.png new file mode 100755 index 000000000..475bbdb90 Binary files /dev/null and b/data/images/objects/candle/torch/torch1.png differ diff --git a/data/images/objects/candle/torch/torch2.png b/data/images/objects/candle/torch/torch2.png new file mode 100755 index 000000000..340a406c4 Binary files /dev/null and b/data/images/objects/candle/torch/torch2.png differ diff --git a/data/images/objects/candle/torch/torch3.png b/data/images/objects/candle/torch/torch3.png new file mode 100755 index 000000000..60757fbb2 Binary files /dev/null and b/data/images/objects/candle/torch/torch3.png differ diff --git a/data/images/objects/candle/torch/torch4.png b/data/images/objects/candle/torch/torch4.png new file mode 100755 index 000000000..897245a52 Binary files /dev/null and b/data/images/objects/candle/torch/torch4.png differ diff --git a/data/images/objects/lightmap_light/lightmap_light-small.png b/data/images/objects/lightmap_light/lightmap_light-small.png new file mode 100644 index 000000000..f4239c3de Binary files /dev/null and b/data/images/objects/lightmap_light/lightmap_light-small.png differ diff --git a/data/images/objects/lightmap_light/lightmap_light-small.sprite b/data/images/objects/lightmap_light/lightmap_light-small.sprite new file mode 100644 index 000000000..350efca9f --- /dev/null +++ b/data/images/objects/lightmap_light/lightmap_light-small.sprite @@ -0,0 +1,7 @@ +(supertux-sprite + (action + (name "default") + (images "lightmap_light-small.png") + (hitbox 64 64 0 0) + ) +) diff --git a/src/object/bullet.cpp b/src/object/bullet.cpp index a4da53ae9..a2e76e84a 100644 --- a/src/object/bullet.cpp +++ b/src/object/bullet.cpp @@ -14,8 +14,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include "math/random_generator.hpp" #include "object/bullet.hpp" #include "object/camera.hpp" +#include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" #include "supertux/globals.hpp" #include "supertux/sector.hpp" @@ -29,6 +31,8 @@ Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type) : physic(), life_count(3), sprite(), + light(0.0f,0.0f,0.0f), + lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")), type(type) { float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM; @@ -36,7 +40,9 @@ Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type) : if(type == FIRE_BONUS) { sprite = sprite_manager->create("images/objects/bullets/firebullet.sprite"); - } else if(type == ICE_BONUS) { + lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE)); + lightsprite->set_color(Color(0.3f, 0.1f, 0.0f)); + } else if(type == ICE_BONUS) { life_count = 10; sprite = sprite_manager->create("images/objects/bullets/icebullet.sprite"); } else { @@ -56,6 +62,11 @@ Bullet::~Bullet() void Bullet::update(float elapsed_time) { + // cause fireball color to flicker randomly + if (gameRandom.rand(5) != 0) { + lightsprite->set_color(Color(0.3f + gameRandom.rand(10)/100.0f, 0.1f + gameRandom.rand(20)/100.0f, gameRandom.rand(10)/100.0f)); + } else + lightsprite->set_color(Color(0.3f, 0.1f, 0.0f)); // remove bullet when it's offscreen float scroll_x = Sector::current()->camera->get_translation().x; @@ -76,7 +87,18 @@ Bullet::update(float elapsed_time) void Bullet::draw(DrawingContext& context) { + //Draw the Sprite. sprite->draw(context, get_pos(), LAYER_OBJECTS); + //Draw the light if fire and dark + if(type == FIRE_BONUS){ + context.get_light( get_bbox().get_middle(), &light ); + if (light.red + light.green < 2.0){ + context.push_target(); + context.set_target(DrawingContext::LIGHTMAP); + lightsprite->draw(context, get_bbox().get_middle(), 0); + context.pop_target(); + } + } } void diff --git a/src/object/bullet.hpp b/src/object/bullet.hpp index 90977eac4..82ea841be 100644 --- a/src/object/bullet.hpp +++ b/src/object/bullet.hpp @@ -49,6 +49,8 @@ private: Physic physic; int life_count; SpritePtr sprite; + Color light; + SpritePtr lightsprite; BonusType type; };