Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corrupted crusher not spawning roots when hit.top #2584

Merged
merged 2 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions data/images/creatures/crusher/corrupted/krosh_corrupt.sprite
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
(supertux-sprite
(action
(name "idle")
(hitbox 16 16 128 128)
(images "krosh_corrupt_main.png"
)
)
(action
(name "crushing")
(hitbox 16 16 128 128)
(images "krosh_corrupt_hit.png"
)
)
(action
(name "recovering")
(hitbox 16 16 128 128)
(images "krosh_corrupt_main.png"
)
)
(action
(name "whites")
(hitbox 16 16 128 128)
(images "krosh_corrupt_whites.png")
)
(action
(name "lefteye")
(hitbox 16 16 128 128)
(images "krosh_corrupt_eyes.png")
)
(action
(name "righteye")
(hitbox 16 16 128 128)
(images "krosh_corrupt_eyes.png")
)
)
(supertux-sprite
(action
(name "idle")
(hitbox 16 16 128 128)
(images "krosh_corrupt_main.png"
)
)
(action
(name "crushing")
(hitbox 16 16 128 128)
(images "krosh_corrupt_hit.png"
)
)
(action
(name "recovering")
(hitbox 16 16 128 128)
(images "krosh_corrupt_main.png"
)
)
(action
(name "whites")
(hitbox 16 16 128 128)
(images "krosh_corrupt_whites.png")
)
(action
(name "lefteye")
(hitbox 16 16 128 128)
(images "krosh_corrupt_eyes.png")
)
(action
(name "righteye")
(hitbox 16 16 128 128)
(images "krosh_corrupt_eyes.png")
)
)
14 changes: 7 additions & 7 deletions data/images/creatures/crusher/corrupted/krosh_eye_glow.sprite
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(supertux-sprite
(action
(name "default")
(hitbox 16 16 128 128)
(images "krosh_eye_glow.png")
)
)
(supertux-sprite
(action
(name "default")
(hitbox 16 16 128 128)
(images "krosh_eye_glow.png")
)
)
70 changes: 35 additions & 35 deletions data/images/creatures/crusher/corrupted/krush_corrupt.sprite
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
(supertux-sprite
(action
(name "idle")
(hitbox 8 8 64 64)
(images "krush_corrupt_main.png"
)
)
(action
(name "crushing")
(hitbox 8 8 64 64)
(images "krush_corrupt_hit.png"
)
)
(action
(name "recovering")
(hitbox 8 8 64 64)
(images "krush_corrupt_main.png"
)
)
(action
(name "whites")
(hitbox 8 8 64 64)
(images "krush_corrupt_whites.png")
)
(action
(name "lefteye")
(hitbox 8 8 64 64)
(images "krush_corrupt_eyes.png")
)
(action
(name "righteye")
(hitbox 8 8 64 64)
(images "krush_corrupt_eyes.png")
)
)
(supertux-sprite
(action
(name "idle")
(hitbox 8 8 64 64)
(images "krush_corrupt_main.png"
)
)
(action
(name "crushing")
(hitbox 8 8 64 64)
(images "krush_corrupt_hit.png"
)
)
(action
(name "recovering")
(hitbox 8 8 64 64)
(images "krush_corrupt_main.png"
)
)
(action
(name "whites")
(hitbox 8 8 64 64)
(images "krush_corrupt_whites.png")
)
(action
(name "lefteye")
(hitbox 8 8 64 64)
(images "krush_corrupt_eyes.png")
)
(action
(name "righteye")
(hitbox 8 8 64 64)
(images "krush_corrupt_eyes.png")
)
)
14 changes: 7 additions & 7 deletions data/images/creatures/crusher/corrupted/krush_eye_glow.sprite
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(supertux-sprite
(action
(name "default")
(hitbox 8 8 64 64)
(images "krush_corrupt_main.png")
)
)
(supertux-sprite
(action
(name "default")
(hitbox 8 8 64 64)
(images "krush_corrupt_main.png")
)
)
59 changes: 32 additions & 27 deletions data/images/creatures/crusher/roots/crusher_root.sprite
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
(supertux-sprite
(action
(name "default")
(hitbox 6 32 20 60)
(images "root-empty.png")
)
(action
(name "downwards")
(fps 16)
(hitbox 6 32 20 60)
(images
"root-0.png"
"root-1.png"
"root-2.png"
"root-3.png"
"root-4.png"
"root-5.png"
"root-5.png"
"root-4.png"
"root-3.png"
"root-2.png"
"root-1.png"
"root-0.png"
)
(loops 1)
)
)
(supertux-sprite
(action
(name "default")
(hitbox 6 32 20 60)
(images "root-empty.png")
)
(action
(name "downwards")
(fps 16)
(hitbox 6 32 20 60)
(images
"root-0.png"
"root-1.png"
"root-2.png"
"root-3.png"
"root-4.png"
"root-5.png"
"root-5.png"
"root-4.png"
"root-3.png"
"root-2.png"
"root-1.png"
"root-0.png"
)
(loops 1)
)
(action
(name "upwards")
(hitbox 6 4 20 60)
(flip-action "downwards")
)
)
68 changes: 34 additions & 34 deletions data/images/creatures/crusher/roots/crusher_root_side.sprite
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
(supertux-sprite
(action
(name "default")
(hitbox 6 6 60 20)
(images "root_side-empty.png")
)
(action
(name "sideways-left")
(fps 16)
(hitbox 6 6 60 20)
(images
"root_side-0.png"
"root_side-1.png"
"root_side-2.png"
"root_side-3.png"
"root_side-4.png"
"root_side-5.png"
"root_side-5.png"
"root_side-4.png"
"root_side-3.png"
"root_side-2.png"
"root_side-1.png"
"root_side-0.png"
)
(loops 1)
)
(action
(name "sideways-right")
(fps 16)
(hitbox 32 6 60 20)
(mirror-action "sideways-left")
(loops 1)
)
)
(supertux-sprite
(action
(name "default")
(hitbox 6 6 60 20)
(images "root_side-empty.png")
)
(action
(name "sideways-left")
(fps 16)
(hitbox 6 6 60 20)
(images
"root_side-0.png"
"root_side-1.png"
"root_side-2.png"
"root_side-3.png"
"root_side-4.png"
"root_side-5.png"
"root_side-5.png"
"root_side-4.png"
"root_side-3.png"
"root_side-2.png"
"root_side-1.png"
"root_side-0.png"
)
(loops 1)
)
(action
(name "sideways-right")
(fps 16)
(hitbox 32 6 60 20)
(mirror-action "sideways-left")
(loops 1)
)
)
27 changes: 20 additions & 7 deletions src/badguy/crusher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ Crusher::collision_solid(const CollisionHit& hit)
}
if (hit.bottom)
spawn_roots(Direction::DOWN);
if (hit.left)
else if (hit.top)
spawn_roots(Direction::UP);
else if (hit.left)
spawn_roots(Direction::LEFT);
if (hit.right)
else if (hit.right)
spawn_roots(Direction::RIGHT);
break;
default:
Expand Down Expand Up @@ -373,6 +375,15 @@ Crusher::spawn_roots(Direction direction)
test_solid_offset_2 = Rectf(Vector(16, 8), Size(1, 1));
break;

case Direction::UP:
vertical = true;
origin.x = m_col.m_bbox.get_middle().x - 16.f;
origin.y = m_col.m_bbox.get_top() - 6.f;
test_empty_offset = Rectf(Vector(4, 4), Size(16, 1));
test_solid_offset_1 = Rectf(Vector(6, -8), Size(1, 1));
test_solid_offset_2 = Rectf(Vector(16, -8), Size(1, 1));
break;

case Direction::LEFT:
origin.x = m_col.m_bbox.get_left() - 6.f;
origin.y = m_col.m_bbox.get_middle().y - 16.f;
Expand Down Expand Up @@ -402,7 +413,6 @@ Crusher::spawn_roots(Direction direction)
bool solid_2 = Sector::current()->is_free_of_tiles(test_solid_offset_2.moved(pos));
bool empty = Sector::current()->is_free_of_tiles(test_empty_offset.moved(pos));

printf("Empty %d, solid1 %d, solid2 %d\n", empty, solid_1, solid_2);
if (!empty || solid_1 || solid_2)
break;

Expand Down Expand Up @@ -611,7 +621,7 @@ Crusher::on_flip(float height)
}

CrusherRoot::CrusherRoot(Vector position, Crusher::Direction direction, float delay, int layer) :
MovingSprite(position, direction == Crusher::Direction::DOWN ?
MovingSprite(position, direction == Crusher::Direction::DOWN || direction == Crusher::Direction::UP ?
"images/creatures/crusher/roots/crusher_root.sprite" :
"images/creatures/crusher/roots/crusher_root_side.sprite"),
m_original_pos(position),
Expand Down Expand Up @@ -672,6 +682,7 @@ CrusherRoot::update(float dt_sec)
m_col.move_to(m_original_pos + Vector(0, -m_sprite->get_current_hitbox_height()));
break;

case Crusher::Direction::UP:
case Crusher::Direction::LEFT:
m_col.move_to(m_original_pos);
break;
Expand All @@ -691,19 +702,21 @@ CrusherRoot::start_animation()
{
case Crusher::Direction::DOWN:
set_action("downwards");
m_sprite->set_animation_loops(1);
break;

case Crusher::Direction::UP:
set_action("upwards");
break;

case Crusher::Direction::LEFT:
set_action("sideways-left");
m_sprite->set_animation_loops(1);
break;

case Crusher::Direction::RIGHT:
set_action("sideways-right");
m_sprite->set_animation_loops(1);
break;
}
m_sprite->set_animation_loops(1);
}

/* EOF */
2 changes: 1 addition & 1 deletion src/badguy/crusher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define HEADER_SUPERTUX_OBJECT_CRUSHER_HPP

#include "object/moving_sprite.hpp"
#include "supertux/direction.hpp"
#include "supertux/physic.hpp"

class Player;
Expand All @@ -37,6 +36,7 @@ class Crusher final : public MovingSprite
enum class Direction
{
DOWN,
UP,
LEFT,
RIGHT
};
Expand Down
Loading