From: Stephen Groundwater Date: Tue, 4 Jul 2006 14:58:28 +0000 (+0000) Subject: Changed MrBomb to a CherryBomb. Added Particles to Mr.Tree, Posion Ivy and ResetPoint... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4f1aaead7061c8cee1704f887fc7e1a2bc7b387c;p=supertux.git Changed MrBomb to a CherryBomb. Added Particles to Mr.Tree, Posion Ivy and ResetPoint-FireFly SVN-Revision: 3871 --- diff --git a/data/images/creatures/mr_cherry/cherry.sprite b/data/images/creatures/mr_cherry/cherry.sprite new file mode 100644 index 000000000..950e0f92a --- /dev/null +++ b/data/images/creatures/mr_cherry/cherry.sprite @@ -0,0 +1,31 @@ +(supertux-sprite + + (action + (name "ticking-left") + (fps 4.0) + (hitbox 7 23 38 43) + (images cherrybomb_hit_1.png +cherrybomb_hit_2.png +cherrybomb_hit_3.png +cherrybomb_hit_4.png +cherrybomb_hit_5.png +)) + + (action + (name "ticking-right") + (fps 4.0) + (hitbox 7 23 38 43) + (mirror-action "ticking-left")) + + (action + (name "explosion") + (fps 5.0) + (hitbox 32 32 31.8 31.8) + (images sparkle-1.png +sparkle-2.png +sparkle-3.png +sparkle-4.png +sparkle-5.png +)) +) + diff --git a/data/images/creatures/mr_cherry/cherrybomb.png b/data/images/creatures/mr_cherry/cherrybomb.png new file mode 100644 index 000000000..bf69088ec Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb.xcf b/data/images/creatures/mr_cherry/cherrybomb.xcf new file mode 100644 index 000000000..a44781430 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb.xcf differ diff --git a/data/images/creatures/mr_cherry/cherrybomb1.png b/data/images/creatures/mr_cherry/cherrybomb1.png new file mode 100644 index 000000000..79319149f Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb1.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb2.png b/data/images/creatures/mr_cherry/cherrybomb2.png new file mode 100644 index 000000000..f84f852c9 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb2.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb3.png b/data/images/creatures/mr_cherry/cherrybomb3.png new file mode 100644 index 000000000..e9257adf5 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb3.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb4.png b/data/images/creatures/mr_cherry/cherrybomb4.png new file mode 100644 index 000000000..90fe5ccd5 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb4.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb5.png b/data/images/creatures/mr_cherry/cherrybomb5.png new file mode 100644 index 000000000..03e1cae22 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb5.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb6.png b/data/images/creatures/mr_cherry/cherrybomb6.png new file mode 100644 index 000000000..e6334fdcc Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb6.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb_hit_1.png b/data/images/creatures/mr_cherry/cherrybomb_hit_1.png new file mode 100644 index 000000000..359fc93fe Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb_hit_1.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb_hit_2.png b/data/images/creatures/mr_cherry/cherrybomb_hit_2.png new file mode 100644 index 000000000..3719f8da0 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb_hit_2.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb_hit_3.png b/data/images/creatures/mr_cherry/cherrybomb_hit_3.png new file mode 100644 index 000000000..81a6fa6de Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb_hit_3.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb_hit_4.png b/data/images/creatures/mr_cherry/cherrybomb_hit_4.png new file mode 100644 index 000000000..f25b51192 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb_hit_4.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb_hit_5.png b/data/images/creatures/mr_cherry/cherrybomb_hit_5.png new file mode 100644 index 000000000..83cab3a27 Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb_hit_5.png differ diff --git a/data/images/creatures/mr_cherry/cherrybomb_hit_6.png b/data/images/creatures/mr_cherry/cherrybomb_hit_6.png new file mode 100644 index 000000000..39b6e1b2b Binary files /dev/null and b/data/images/creatures/mr_cherry/cherrybomb_hit_6.png differ diff --git a/data/images/creatures/mr_cherry/mr_cherry.sprite b/data/images/creatures/mr_cherry/mr_cherry.sprite new file mode 100644 index 000000000..733a0d8bc --- /dev/null +++ b/data/images/creatures/mr_cherry/mr_cherry.sprite @@ -0,0 +1,21 @@ +(supertux-sprite + (action + (name "left") + (fps 10.0) + (hitbox 7 23 38 43) + (images "cherrybomb.png" + "cherrybomb1.png" + "cherrybomb2.png" + "cherrybomb3.png" + "cherrybomb4.png" + "cherrybomb5.png" + +)) + + (action + (name "right") + (fps 10.0) + (hitbox 7 23 38 43) + (mirror-action "left")) + +) diff --git a/data/images/creatures/mr_cherry/sparkle-1.png b/data/images/creatures/mr_cherry/sparkle-1.png new file mode 100644 index 000000000..622893239 Binary files /dev/null and b/data/images/creatures/mr_cherry/sparkle-1.png differ diff --git a/data/images/creatures/mr_cherry/sparkle-2.png b/data/images/creatures/mr_cherry/sparkle-2.png new file mode 100644 index 000000000..723cd2e69 Binary files /dev/null and b/data/images/creatures/mr_cherry/sparkle-2.png differ diff --git a/data/images/creatures/mr_cherry/sparkle-3.png b/data/images/creatures/mr_cherry/sparkle-3.png new file mode 100644 index 000000000..90b0a4122 Binary files /dev/null and b/data/images/creatures/mr_cherry/sparkle-3.png differ diff --git a/data/images/creatures/mr_cherry/sparkle-4.png b/data/images/creatures/mr_cherry/sparkle-4.png new file mode 100644 index 000000000..c3b3f443a Binary files /dev/null and b/data/images/creatures/mr_cherry/sparkle-4.png differ diff --git a/data/images/creatures/mr_cherry/sparkle-5.png b/data/images/creatures/mr_cherry/sparkle-5.png new file mode 100644 index 000000000..81c26e190 Binary files /dev/null and b/data/images/creatures/mr_cherry/sparkle-5.png differ diff --git a/data/images/creatures/mr_cherry/sparkle-6.png b/data/images/creatures/mr_cherry/sparkle-6.png new file mode 100644 index 000000000..a06eba15b Binary files /dev/null and b/data/images/creatures/mr_cherry/sparkle-6.png differ diff --git a/data/images/creatures/mr_cherry/sparkle.xcf b/data/images/creatures/mr_cherry/sparkle.xcf new file mode 100644 index 000000000..4de57c60f Binary files /dev/null and b/data/images/creatures/mr_cherry/sparkle.xcf differ diff --git a/data/images/creatures/mr_tree/squished-left.png b/data/images/creatures/mr_tree/squished-left.png index 44b59b377..d75edfb89 100644 Binary files a/data/images/creatures/mr_tree/squished-left.png and b/data/images/creatures/mr_tree/squished-left.png differ diff --git a/data/images/creatures/mr_tree/walk-left-1.png b/data/images/creatures/mr_tree/walk-left-1.png index 07375a7f1..eaabb0858 100644 Binary files a/data/images/creatures/mr_tree/walk-left-1.png and b/data/images/creatures/mr_tree/walk-left-1.png differ diff --git a/data/images/creatures/mr_tree/walk-left-2.png b/data/images/creatures/mr_tree/walk-left-2.png index 83f892acd..610564d89 100644 Binary files a/data/images/creatures/mr_tree/walk-left-2.png and b/data/images/creatures/mr_tree/walk-left-2.png differ diff --git a/data/images/creatures/mr_tree/walk-left-3.png b/data/images/creatures/mr_tree/walk-left-3.png index 3ed3e72a4..dcbbc614a 100644 Binary files a/data/images/creatures/mr_tree/walk-left-3.png and b/data/images/creatures/mr_tree/walk-left-3.png differ diff --git a/data/images/creatures/mr_tree/walk-left-4.png b/data/images/creatures/mr_tree/walk-left-4.png index b115f0f8a..060da714f 100644 Binary files a/data/images/creatures/mr_tree/walk-left-4.png and b/data/images/creatures/mr_tree/walk-left-4.png differ diff --git a/data/images/creatures/mr_tree/walk-left-5.png b/data/images/creatures/mr_tree/walk-left-5.png index fbb9ac96a..2722354c6 100644 Binary files a/data/images/creatures/mr_tree/walk-left-5.png and b/data/images/creatures/mr_tree/walk-left-5.png differ diff --git a/data/images/creatures/mr_tree/walk-left-6.png b/data/images/creatures/mr_tree/walk-left-6.png index 4435b861a..a8ca5942f 100644 Binary files a/data/images/creatures/mr_tree/walk-left-6.png and b/data/images/creatures/mr_tree/walk-left-6.png differ diff --git a/data/images/creatures/poison_ivy/squished.png b/data/images/creatures/poison_ivy/squished.png index 4ca865107..57d6467a9 100644 Binary files a/data/images/creatures/poison_ivy/squished.png and b/data/images/creatures/poison_ivy/squished.png differ diff --git a/data/images/objects/particles/bark-0.png b/data/images/objects/particles/bark-0.png new file mode 100644 index 000000000..e54b7b48f Binary files /dev/null and b/data/images/objects/particles/bark-0.png differ diff --git a/data/images/objects/particles/bark.sprite b/data/images/objects/particles/bark.sprite new file mode 100644 index 000000000..ace0f46a6 --- /dev/null +++ b/data/images/objects/particles/bark.sprite @@ -0,0 +1,9 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "bark-0.png" + ) + ) +) diff --git a/data/images/objects/particles/kracker-1.png b/data/images/objects/particles/kracker-1.png new file mode 100644 index 000000000..212f33216 Binary files /dev/null and b/data/images/objects/particles/kracker-1.png differ diff --git a/data/images/objects/particles/kracker-2.png b/data/images/objects/particles/kracker-2.png new file mode 100644 index 000000000..174ac9a5b Binary files /dev/null and b/data/images/objects/particles/kracker-2.png differ diff --git a/data/images/objects/particles/kracker-3.png b/data/images/objects/particles/kracker-3.png new file mode 100644 index 000000000..2e4fe34bf Binary files /dev/null and b/data/images/objects/particles/kracker-3.png differ diff --git a/data/images/objects/particles/kracker-4.png b/data/images/objects/particles/kracker-4.png new file mode 100644 index 000000000..47f8e80d0 Binary files /dev/null and b/data/images/objects/particles/kracker-4.png differ diff --git a/data/images/objects/particles/kracker-5.png b/data/images/objects/particles/kracker-5.png new file mode 100644 index 000000000..82d4b39d2 Binary files /dev/null and b/data/images/objects/particles/kracker-5.png differ diff --git a/data/images/objects/particles/kracker-6.png b/data/images/objects/particles/kracker-6.png new file mode 100644 index 000000000..f9f4066c5 Binary files /dev/null and b/data/images/objects/particles/kracker-6.png differ diff --git a/data/images/objects/particles/kracker-7.png b/data/images/objects/particles/kracker-7.png new file mode 100644 index 000000000..bce57c51a Binary files /dev/null and b/data/images/objects/particles/kracker-7.png differ diff --git a/data/images/objects/particles/kracker-8.png b/data/images/objects/particles/kracker-8.png new file mode 100644 index 000000000..5175d82b2 Binary files /dev/null and b/data/images/objects/particles/kracker-8.png differ diff --git a/data/images/objects/particles/kracker-9.png b/data/images/objects/particles/kracker-9.png new file mode 100644 index 000000000..ff3d8016b Binary files /dev/null and b/data/images/objects/particles/kracker-9.png differ diff --git a/data/images/objects/particles/kracker.sprite b/data/images/objects/particles/kracker.sprite new file mode 100644 index 000000000..38eb30941 --- /dev/null +++ b/data/images/objects/particles/kracker.sprite @@ -0,0 +1,18 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "kracker-1.png" + "kracker-2.png" +"kracker-3.png" +"kracker-4.png" +"kracker-5.png" +"kracker-6.png" +"kracker-7.png" +"kracker-8.png" +"kracker-9.png" + + ) + ) +) diff --git a/data/images/objects/particles/kracker.sprite~ b/data/images/objects/particles/kracker.sprite~ new file mode 100644 index 000000000..38b599bdb --- /dev/null +++ b/data/images/objects/particles/kracker.sprite~ @@ -0,0 +1,17 @@ +(supertux-sprite + (action + (name "default") + (images + "kracker-1.png" + "kracker-2.png" +"kracker-3.png" +"kracker-4.png" +"kracker-5.png" +"kracker-6.png" +"kracker-7.png" +"kracker-8.png" +"kracker-9.png" + + ) + ) +) diff --git a/data/images/objects/particles/kraker.sprite b/data/images/objects/particles/kraker.sprite new file mode 100644 index 000000000..a602d18de --- /dev/null +++ b/data/images/objects/particles/kraker.sprite @@ -0,0 +1,9 @@ +(supertux-sprite + (action + (name "default") + (images + "kracker-1.png" + + ) + ) +) diff --git a/data/images/objects/particles/kraker.sprite~ b/data/images/objects/particles/kraker.sprite~ new file mode 100644 index 000000000..a602d18de --- /dev/null +++ b/data/images/objects/particles/kraker.sprite~ @@ -0,0 +1,9 @@ +(supertux-sprite + (action + (name "default") + (images + "kracker-1.png" + + ) + ) +) diff --git a/data/images/objects/particles/leaf-0.png b/data/images/objects/particles/leaf-0.png new file mode 100644 index 000000000..e535d05a0 Binary files /dev/null and b/data/images/objects/particles/leaf-0.png differ diff --git a/data/images/objects/particles/leaf.sprite b/data/images/objects/particles/leaf.sprite new file mode 100644 index 000000000..82336c336 --- /dev/null +++ b/data/images/objects/particles/leaf.sprite @@ -0,0 +1,9 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "leaf-0.png" + ) + ) +) diff --git a/data/images/objects/particles/leaf.sprite~ b/data/images/objects/particles/leaf.sprite~ new file mode 100644 index 000000000..82336c336 --- /dev/null +++ b/data/images/objects/particles/leaf.sprite~ @@ -0,0 +1,9 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "leaf-0.png" + ) + ) +) diff --git a/data/images/objects/particles/poisonivy-0.png b/data/images/objects/particles/poisonivy-0.png new file mode 100644 index 000000000..7c43b56c6 Binary files /dev/null and b/data/images/objects/particles/poisonivy-0.png differ diff --git a/data/images/objects/particles/poisonivy-1.png b/data/images/objects/particles/poisonivy-1.png new file mode 100644 index 000000000..fc2b27c35 Binary files /dev/null and b/data/images/objects/particles/poisonivy-1.png differ diff --git a/data/images/objects/particles/poisonivy-2.png b/data/images/objects/particles/poisonivy-2.png new file mode 100644 index 000000000..e11594c82 Binary files /dev/null and b/data/images/objects/particles/poisonivy-2.png differ diff --git a/data/images/objects/particles/poisonivy-3.png b/data/images/objects/particles/poisonivy-3.png new file mode 100644 index 000000000..9d94640cd Binary files /dev/null and b/data/images/objects/particles/poisonivy-3.png differ diff --git a/data/images/objects/particles/poisonivy.png b/data/images/objects/particles/poisonivy.png new file mode 100644 index 000000000..a7c79e80d Binary files /dev/null and b/data/images/objects/particles/poisonivy.png differ diff --git a/data/images/objects/particles/poisonivy.sprite b/data/images/objects/particles/poisonivy.sprite new file mode 100644 index 000000000..aa73c32ec --- /dev/null +++ b/data/images/objects/particles/poisonivy.sprite @@ -0,0 +1,12 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "poisonivy-0.png" +"poisonivy-1.png" +"poisonivy-2.png" +"poisonivy-3.png" + ) + ) +) diff --git a/data/images/objects/particles/poisonivy.sprite~ b/data/images/objects/particles/poisonivy.sprite~ new file mode 100644 index 000000000..16cc221cc --- /dev/null +++ b/data/images/objects/particles/poisonivy.sprite~ @@ -0,0 +1,9 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "poisonivy-0.png" + ) + ) +) diff --git a/data/images/objects/particles/reset.png b/data/images/objects/particles/reset.png new file mode 100644 index 000000000..bcf0e716c Binary files /dev/null and b/data/images/objects/particles/reset.png differ diff --git a/data/images/objects/particles/reset.sprite b/data/images/objects/particles/reset.sprite new file mode 100644 index 000000000..92ff46665 --- /dev/null +++ b/data/images/objects/particles/reset.sprite @@ -0,0 +1,10 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "reset.png" + + ) + ) +) diff --git a/data/images/objects/particles/reset.sprite~ b/data/images/objects/particles/reset.sprite~ new file mode 100644 index 000000000..e0f32483f --- /dev/null +++ b/data/images/objects/particles/reset.sprite~ @@ -0,0 +1,10 @@ +(supertux-sprite + (action + (name "default") +(fps 4.0) + (images + "cloud.png" + + ) + ) +) diff --git a/data/levels/world2/castledoor.stl b/data/levels/world2/castledoor.stl index 02f7b4af0..c549b2ccb 100644 --- a/data/levels/world2/castledoor.stl +++ b/data/levels/world2/castledoor.stl @@ -5,6 +5,16 @@ (sector (name "main") (music "music/forest2.ogg") + (mrbomb + (direction "auto") + (x 370.397) + (y 503.8701) + ) + (mrbomb + (direction "auto") + (x 257.2599) + (y 503.8701) + ) (firefly (x 429.1299) (y 344.6518) diff --git a/data/sounds/fizz.wav b/data/sounds/fizz.wav new file mode 100644 index 000000000..dce8b0f13 Binary files /dev/null and b/data/sounds/fizz.wav differ diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index 7d30a436d..4b70b2135 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -27,7 +27,7 @@ static const float TICKINGTIME = 1; static const float EXPLOSIONTIME = 1; Bomb::Bomb(const Vector& pos, Direction dir) - : BadGuy(pos, "images/creatures/mr_bomb/bomb.sprite") + : BadGuy(pos, "images/creatures/mr_cherry/cherry.sprite") { state = STATE_TICKING; timer.start(TICKINGTIME); @@ -35,7 +35,7 @@ Bomb::Bomb(const Vector& pos, Direction dir) sprite->set_action(dir == LEFT ? "ticking-left" : "ticking-right"); countMe = false; - ticking.reset(sound_manager->create_sound_source("sounds/ticking.wav")); + ticking.reset(sound_manager->create_sound_source("sounds/fizz.wav")); ticking->set_position(get_pos()); ticking->set_looping(true); ticking->set_gain(2.0); @@ -47,7 +47,7 @@ Bomb::Bomb(const Bomb& other) : BadGuy(other), state(other.state), timer(other.timer) { if (state == STATE_TICKING) { - ticking.reset(sound_manager->create_sound_source("sounds/ticking.wav")); + ticking.reset(sound_manager->create_sound_source("sounds/fizz.wav")); ticking->set_position(get_pos()); ticking->set_looping(true); ticking->set_gain(2.0); @@ -116,18 +116,18 @@ Bomb::explode() sound_manager->play("sounds/explosion.wav", get_pos()); timer.start(EXPLOSIONTIME); - // spawn some particles - // TODO: provide convenience function in MovingSprite or MovingObject? - for (int i = 0; i < 100; i++) { - Vector ppos = bbox.get_middle(); - float angle = systemRandom.randf(-M_PI_2, M_PI_2); - float velocity = systemRandom.randf(450, 900); - float vx = sin(angle)*velocity; - float vy = -cos(angle)*velocity; - Vector pspeed = Vector(vx, vy); - Vector paccel = Vector(0, 1000); - Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); - } +// spawn some particles + // TODO: provide convenience function in MovingSprite or MovingObject? + for (int i = 0; i < 100; i++) { + Vector ppos = bbox.get_middle(); + float angle = systemRandom.randf(-M_PI_2, M_PI_2); + float velocity = systemRandom.randf(450, 900); + float vx = sin(angle)*velocity; + float vy = -cos(angle)*velocity; + Vector pspeed = Vector(vx, vy); + Vector paccel = Vector(0, 1000); + Sector::current()->add_object(new SpriteParticle("images/objects/particles/kracker.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); + } } diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 280596e6d..0421edddd 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -25,7 +25,7 @@ static const float WALKSPEED = 80; MrBomb::MrBomb(const lisp::Lisp& reader) - : BadGuy(reader, "images/creatures/mr_bomb/mr_bomb.sprite") + : BadGuy(reader, "images/creatures/mr_cherry/mr_cherry.sprite") { set_direction = false; reader.get("direction", direction); @@ -36,7 +36,7 @@ MrBomb::MrBomb(const lisp::Lisp& reader) } MrBomb::MrBomb(const Vector& pos, Direction d) - : BadGuy(pos, "images/creatures/mr_bomb/mr_bomb.sprite") + : BadGuy(pos, "images/creatures/mr_cherry/mr_cherry.sprite") { set_direction = true; initial_direction = d; diff --git a/src/badguy/mrtree.cpp b/src/badguy/mrtree.cpp index a555a427a..40ed3563b 100644 --- a/src/badguy/mrtree.cpp +++ b/src/badguy/mrtree.cpp @@ -21,6 +21,8 @@ #include "mrtree.hpp" #include "poisonivy.hpp" +#include "random_generator.hpp" +#include "object/sprite_particle.hpp" static const float WALKSPEED = 100; static const float WALKSPEED_SMALL = 120; @@ -119,7 +121,18 @@ MrTree::collision_squished(Player& player) sound_manager->play("sounds/mr_tree.ogg", get_pos()); player.bounce(*this); - + // spawn some particles + // TODO: provide convenience function in MovingSprite or MovingObject? + for (int i = 0; i < 25; i++) { + Vector ppos = bbox.get_middle(); + float angle = systemRandom.randf(-M_PI_2, M_PI_2); + float velocity = systemRandom.randf(45, 90); + float vx = sin(angle)*velocity; + float vy = -cos(angle)*velocity; + Vector pspeed = Vector(vx, vy); + Vector paccel = Vector(0, 100); + Sector::current()->add_object(new SpriteParticle("images/objects/particles/leaf.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); + } Vector leaf1_pos = Vector(pos.x - POISONIVY_WIDTH - 1, pos.y - POISONIVY_Y_OFFSET); Rect leaf1_bbox = Rect(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + POISONIVY_WIDTH, leaf1_pos.y + POISONIVY_HEIGHT); if (Sector::current()->is_free_space(leaf1_bbox)) { @@ -148,7 +161,21 @@ MrTree::collision_squished(Player& player) sprite->set_action(dir == LEFT ? "squished-left" : "squished-right"); bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); kill_squished(player); + // spawn some particles + // TODO: provide convenience function in MovingSprite or MovingObject? + for (int i = 0; i < 25; i++) { + Vector ppos = bbox.get_middle(); + float angle = systemRandom.randf(-M_PI_2, M_PI_2); + float velocity = systemRandom.randf(45, 90); + float vx = sin(angle)*velocity; + float vy = -cos(angle)*velocity; + Vector pspeed = Vector(vx, vy); + Vector paccel = Vector(0, 100); + Sector::current()->add_object(new SpriteParticle("images/objects/particles/bark.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); + } + return true; + } //TODO: exception? diff --git a/src/badguy/poisonivy.cpp b/src/badguy/poisonivy.cpp index 302fb4c81..dfcfa3d64 100644 --- a/src/badguy/poisonivy.cpp +++ b/src/badguy/poisonivy.cpp @@ -20,6 +20,8 @@ #include #include "poisonivy.hpp" +#include "random_generator.hpp" +#include "object/sprite_particle.hpp" static const float WALKSPEED = 80; @@ -65,6 +67,18 @@ bool PoisonIvy::collision_squished(Player& player) { sprite->set_action(dir == LEFT ? "squished-left" : "squished-right"); + // spawn some particles + // TODO: provide convenience function in MovingSprite or MovingObject? + for (int i = 0; i < 3; i++) { + Vector ppos = bbox.get_middle(); + float angle = systemRandom.randf(-M_PI_2, M_PI_2); + float velocity = systemRandom.randf(350, 400); + float vx = sin(angle)*velocity; + float vy = -cos(angle)*velocity; + Vector pspeed = Vector(vx, vy); + Vector paccel = Vector(0, 100); + Sector::current()->add_object(new SpriteParticle("images/objects/particles/poisonivy.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); + } kill_squished(player); return true; } diff --git a/src/object/firefly.cpp b/src/object/firefly.cpp index dc9adff0b..b9b775967 100644 --- a/src/object/firefly.cpp +++ b/src/object/firefly.cpp @@ -27,6 +27,8 @@ #include "object_factory.hpp" #include "game_session.hpp" #include "sector.hpp" +#include "random_generator.hpp" +#include "object/sprite_particle.hpp" Firefly::Firefly(const lisp::Lisp& lisp) : MovingSprite(lisp, "images/objects/firefly/firefly.sprite", LAYER_TILES, COLGROUP_TOUCHABLE), activated(false) @@ -51,6 +53,18 @@ Firefly::collision(GameObject& other, const CollisionHit& ) Player* player = dynamic_cast (&other); if(player) { activated = true; +// spawn some particles +// TODO: provide convenience function in MovingSprite or MovingObject? + for (int i = 0; i < 5; i++) { + Vector ppos = bbox.get_middle(); + float angle = systemRandom.randf(-M_PI_2, M_PI_2); + float velocity = systemRandom.randf(450, 900); + float vx = sin(angle)*velocity; + float vy = -cos(angle)*velocity; + Vector pspeed = Vector(vx, vy); + Vector paccel = Vector(0, 1000); + Sector::current()->add_object(new SpriteParticle("images/objects/particles/reset.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1)); + } // TODO play sound sprite->set_action("ringing"); GameSession::current()->set_reset_point(Sector::current()->get_name(), diff --git a/src/object/firefly.hpp b/src/object/firefly.hpp index b167b3af7..89a3882aa 100644 --- a/src/object/firefly.hpp +++ b/src/object/firefly.hpp @@ -23,6 +23,7 @@ #include "lisp/lisp.hpp" #include "object/moving_sprite.hpp" #include "serializable.hpp" +#include "badguy/badguy.hpp" /** * A Firefly: When tux touches it, it begins buzzing and you will respawn at this