Skip to content

Commit

Permalink
Add new bouncing snowball sprite (#1573)
Browse files Browse the repository at this point in the history
* New bouncing snowball sprite [ci skip]

* Updates to bouncy snowball

* Fix bugs

* more bugfixes

* fix
  • Loading branch information
weluvgoatz committed Nov 9, 2020
1 parent bf4b7af commit 24d907d
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 8 deletions.
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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 51 additions & 8 deletions data/images/creatures/bouncing_snowball/bouncing_snowball.sprite
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Binary file added data/images/creatures/bouncing_snowball/bs1.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/creatures/bouncing_snowball/bs2.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/creatures/bouncing_snowball/bs3.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/creatures/bouncing_snowball/bs4.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/creatures/bouncing_snowball/bs5.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/creatures/bouncing_snowball/bs6.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/creatures/bouncing_snowball/bs7.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/creatures/bouncing_snowball/bs8.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/badguy/bouncing_snowball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "badguy/bouncing_snowball.hpp"

#include "sprite/sprite.hpp"
#include "supertux/sector.hpp"

#include <algorithm>

Expand All @@ -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)
{
Expand All @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/badguy/bouncing_snowball.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
Expand Down

0 comments on commit 24d907d

Please sign in to comment.