Skip to content

Commit

Permalink
Fireballs glow in the dark, and added basic torch sprite of bug 883
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH0013 committed Apr 9, 2013
1 parent 42570f1 commit 550dce7
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 1 deletion.
Binary file added data/images/objects/candle/candle-light.xcf
Binary file not shown.
Binary file added data/images/objects/candle/torch/torch-off.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions 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"
)
)
)

Binary file added data/images/objects/candle/torch/torch1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/objects/candle/torch/torch2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/objects/candle/torch/torch3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/objects/candle/torch/torch4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,7 @@
(supertux-sprite
(action
(name "default")
(images "lightmap_light-small.png")
(hitbox 64 64 0 0)
)
)
24 changes: 23 additions & 1 deletion src/object/bullet.cpp
Expand Up @@ -14,8 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#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"
Expand All @@ -29,14 +31,18 @@ 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;
physic.set_velocity_x(speed + xm);

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 {
Expand All @@ -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;
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/object/bullet.hpp
Expand Up @@ -49,6 +49,8 @@ class Bullet : public MovingObject
Physic physic;
int life_count;
SpritePtr sprite;
Color light;
SpritePtr lightsprite;
BonusType type;
};

Expand Down

0 comments on commit 550dce7

Please sign in to comment.