diff --git a/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite b/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite index 36439691e10..f1783a7fa25 100644 --- a/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite +++ b/data/images/creatures/crusher/corrupted/krosh_corrupt.sprite @@ -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") + ) +) diff --git a/data/images/creatures/crusher/corrupted/krosh_eye_glow.sprite b/data/images/creatures/crusher/corrupted/krosh_eye_glow.sprite index 0ad5f923789..2b0cd54c8cf 100644 --- a/data/images/creatures/crusher/corrupted/krosh_eye_glow.sprite +++ b/data/images/creatures/crusher/corrupted/krosh_eye_glow.sprite @@ -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") + ) +) diff --git a/data/images/creatures/crusher/corrupted/krush_corrupt.sprite b/data/images/creatures/crusher/corrupted/krush_corrupt.sprite index a80bcb0f54c..7cd9c5a713e 100644 --- a/data/images/creatures/crusher/corrupted/krush_corrupt.sprite +++ b/data/images/creatures/crusher/corrupted/krush_corrupt.sprite @@ -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") + ) +) diff --git a/data/images/creatures/crusher/corrupted/krush_eye_glow.sprite b/data/images/creatures/crusher/corrupted/krush_eye_glow.sprite index 4676f27fa80..c3a963ae356 100644 --- a/data/images/creatures/crusher/corrupted/krush_eye_glow.sprite +++ b/data/images/creatures/crusher/corrupted/krush_eye_glow.sprite @@ -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") + ) +) diff --git a/data/images/creatures/crusher/roots/crusher_root.sprite b/data/images/creatures/crusher/roots/crusher_root.sprite index 70cc54f55cc..4f6afb50dba 100644 --- a/data/images/creatures/crusher/roots/crusher_root.sprite +++ b/data/images/creatures/crusher/roots/crusher_root.sprite @@ -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") + ) +) diff --git a/data/images/creatures/crusher/roots/crusher_root_side.sprite b/data/images/creatures/crusher/roots/crusher_root_side.sprite index 40dc095d3fd..0228505280a 100644 --- a/data/images/creatures/crusher/roots/crusher_root_side.sprite +++ b/data/images/creatures/crusher/roots/crusher_root_side.sprite @@ -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) + ) +) diff --git a/src/badguy/crusher.cpp b/src/badguy/crusher.cpp index a702d98e689..c0b52b40168 100644 --- a/src/badguy/crusher.cpp +++ b/src/badguy/crusher.cpp @@ -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: @@ -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; @@ -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; @@ -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), @@ -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; @@ -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 */ diff --git a/src/badguy/crusher.hpp b/src/badguy/crusher.hpp index 6e91b4b2982..c2e07b7ac1e 100644 --- a/src/badguy/crusher.hpp +++ b/src/badguy/crusher.hpp @@ -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; @@ -37,6 +36,7 @@ class Crusher final : public MovingSprite enum class Direction { DOWN, + UP, LEFT, RIGHT };