diff --git a/data/images/creatures/bouncing_snowball/bounce1.png b/data/images/creatures/bouncing_snowball/bounce1.png new file mode 100644 index 00000000000..cfc5d8d52a7 Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bounce1.png differ diff --git a/data/images/creatures/bouncing_snowball/bounce2.png b/data/images/creatures/bouncing_snowball/bounce2.png new file mode 100644 index 00000000000..406b9130046 Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bounce2.png differ diff --git a/data/images/creatures/bouncing_snowball/bounce3.png b/data/images/creatures/bouncing_snowball/bounce3.png new file mode 100644 index 00000000000..5751e29ca6a Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bounce3.png differ diff --git a/data/images/creatures/bouncing_snowball/bouncing_snowball.sprite b/data/images/creatures/bouncing_snowball/bouncing_snowball.sprite index 4282e745af4..bb20c2cd88d 100644 --- a/data/images/creatures/bouncing_snowball/bouncing_snowball.sprite +++ b/data/images/creatures/bouncing_snowball/bouncing_snowball.sprite @@ -1,19 +1,62 @@ (supertux-sprite (action (name "left") - (hitbox 1 0 31.8 31.8) - (images "left-0.png" - "left-1.png" - "left-2.png" - "left-3.png" - "left-4.png" - "left-5.png")) + (hitbox 17 14 31 31) + (fps 20) + (images "bs1.png" + "bs2.png" + "bs3.png" + "bs4.png" + "bs5.png" + "bs6.png" + "bs7.png" + "bs8.png" + "bs8.png" + "bs8.png" + "bs8.png" + "bs8.png")) (action (name "right") - (hitbox 1 0 31.8 31.8) + (hitbox 17 14 31 31) + (fps 20) (mirror-action "left")) + (action + (name "left-down") + (loops 1) + (hitbox 17 14 31 31) + (fps 30) + (images "bs8.png" + "bounce1.png" + "bounce2.png" + "bounce3.png")) + + (action + (name "right-down") + (loops 1) + (hitbox 17 14 31 31) + (fps 30) + (mirror-action "left-down")) + + (action + (name "left-up") + (loops 1) + (hitbox 17 14 31 31) + (fps 30) + (images "bounce3.png" + "bounce3.png" + "bounce2.png" + "bounce1.png" + "bs8.png")) + + (action + (name "right-up") + (loops 1) + (hitbox 17 14 31 31) + (fps 30) + (mirror-action "left-up")) + (action (name "melting-left") (fps 20) diff --git a/data/images/creatures/bouncing_snowball/bs1.png b/data/images/creatures/bouncing_snowball/bs1.png new file mode 100644 index 00000000000..dcc6bf8a8ab Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs1.png differ diff --git a/data/images/creatures/bouncing_snowball/bs2.png b/data/images/creatures/bouncing_snowball/bs2.png new file mode 100644 index 00000000000..0954519b3c4 Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs2.png differ diff --git a/data/images/creatures/bouncing_snowball/bs3.png b/data/images/creatures/bouncing_snowball/bs3.png new file mode 100644 index 00000000000..b547720b5a9 Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs3.png differ diff --git a/data/images/creatures/bouncing_snowball/bs4.png b/data/images/creatures/bouncing_snowball/bs4.png new file mode 100644 index 00000000000..c2524d8bd5b Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs4.png differ diff --git a/data/images/creatures/bouncing_snowball/bs5.png b/data/images/creatures/bouncing_snowball/bs5.png new file mode 100644 index 00000000000..061f79bb9f1 Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs5.png differ diff --git a/data/images/creatures/bouncing_snowball/bs6.png b/data/images/creatures/bouncing_snowball/bs6.png new file mode 100644 index 00000000000..a5659f1e2f3 Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs6.png differ diff --git a/data/images/creatures/bouncing_snowball/bs7.png b/data/images/creatures/bouncing_snowball/bs7.png new file mode 100644 index 00000000000..d3fd3fe6845 Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs7.png differ diff --git a/data/images/creatures/bouncing_snowball/bs8.png b/data/images/creatures/bouncing_snowball/bs8.png new file mode 100644 index 00000000000..a2ee7021b9f Binary files /dev/null and b/data/images/creatures/bouncing_snowball/bs8.png differ diff --git a/src/badguy/bouncing_snowball.cpp b/src/badguy/bouncing_snowball.cpp index 9bc7bec7044..4661aa12ab9 100644 --- a/src/badguy/bouncing_snowball.cpp +++ b/src/badguy/bouncing_snowball.cpp @@ -17,6 +17,7 @@ #include "badguy/bouncing_snowball.hpp" #include "sprite/sprite.hpp" +#include "supertux/sector.hpp" #include @@ -35,6 +36,28 @@ BouncingSnowball::initialize() m_sprite->set_action(m_dir == Direction::LEFT ? "left" : "right"); } +void +BouncingSnowball::active_update(float dt_sec) +{ + BadGuy::active_update(dt_sec); + if ((m_sprite->get_action() == "left-up" || m_sprite->get_action() == "right-up") && m_sprite->animation_done()) + { + m_sprite->set_action(m_dir == Direction::LEFT ? "left" : "right"); + } + Rectf lookbelow = get_bbox(); + lookbelow.set_bottom(lookbelow.get_bottom() + 48); + lookbelow.set_top(lookbelow.get_top() + 31); + bool groundBelow = !Sector::get().is_free_of_statics(lookbelow); + if (groundBelow && (m_physic.get_velocity_y() >= 64.0f)) + { + m_sprite->set_action(m_dir == Direction::LEFT ? "left-down" : "right-down"); + } + if (!groundBelow && (m_sprite->get_action() == "left-down" || m_sprite->get_action() == "right-down")) + { + m_sprite->set_action(m_dir == Direction::LEFT ? "left" : "right"); + } +} + bool BouncingSnowball::collision_squished(GameObject& object) { @@ -55,6 +78,7 @@ BouncingSnowball::collision_solid(const CollisionHit& hit) if (get_state() == STATE_ACTIVE) { float bounce_speed = -m_physic.get_velocity_y()*0.8f; m_physic.set_velocity_y(std::min(JUMPSPEED, bounce_speed)); + m_sprite->set_action(m_dir == Direction::LEFT ? "left-up" : "right-up", /* loops = */ 1); } else { m_physic.set_velocity_y(0); } diff --git a/src/badguy/bouncing_snowball.hpp b/src/badguy/bouncing_snowball.hpp index 23dab5ab5f4..5590e4b0ff4 100644 --- a/src/badguy/bouncing_snowball.hpp +++ b/src/badguy/bouncing_snowball.hpp @@ -25,6 +25,7 @@ class BouncingSnowball final : public BadGuy BouncingSnowball(const ReaderMapping& reader); virtual void initialize() override; + virtual void active_update(float) override; virtual void collision_solid(const CollisionHit& hit) override; virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override; virtual std::string get_class() const override { return "bouncingsnowball"; }