From 7cb51c78532d59f4f52ee8facfadbdcb7031728b Mon Sep 17 00:00:00 2001 From: Kuba Date: Sat, 18 Dec 2021 19:09:55 +0100 Subject: [PATCH] Fix issues introduced in #1922 (#1968) --- src/badguy/badguy.cpp | 1 + src/object/block.cpp | 1 + src/object/decal.cpp | 1 + src/object/flower.cpp | 1 + src/object/platform.cpp | 1 + src/trigger/door.cpp | 16 +++++++++++++--- src/trigger/door.hpp | 3 +++ 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 14c2718ae1b..58b6c89bb29 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -397,6 +397,7 @@ BadGuy::collision_solid(const CollisionHit& hit) void BadGuy::on_flip(float height) { + MovingObject::on_flip(height); Vector pos = get_start_position(); pos.y = height - pos.y; set_start_position(pos); diff --git a/src/object/block.cpp b/src/object/block.cpp index b0a1c7b574a..3cdede02e6f 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -234,6 +234,7 @@ void Block::after_editor_set() void Block::on_flip(float height) { + MovingObject::on_flip(height); if (m_original_y != -1) m_original_y = height - m_original_y - get_bbox().get_height(); } diff --git a/src/object/decal.cpp b/src/object/decal.cpp index a894d05ad9b..12f4924d0c8 100644 --- a/src/object/decal.cpp +++ b/src/object/decal.cpp @@ -106,6 +106,7 @@ Decal::fade_sprite(const std::string& new_sprite, float fade_time) void Decal::on_flip(float height) { + MovingObject::on_flip(height); FlipLevelTransformer::transform_flip(m_flip); } diff --git a/src/object/flower.cpp b/src/object/flower.cpp index aa5d97fa1a6..f4b887260a5 100644 --- a/src/object/flower.cpp +++ b/src/object/flower.cpp @@ -87,6 +87,7 @@ Flower::collision(GameObject& other, const CollisionHit& ) void Flower::on_flip(float height) { + MovingObject::on_flip(height); FlipLevelTransformer::transform_flip(flip); } diff --git a/src/object/platform.cpp b/src/object/platform.cpp index 65f71633d9a..6dfa227f592 100644 --- a/src/object/platform.cpp +++ b/src/object/platform.cpp @@ -149,6 +149,7 @@ Platform::editor_update() void Platform::on_flip(float height) { + MovingObject::on_flip(height); if (Path* path = get_path()) { FlipLevelTransformer::transform_path(height, get_bbox().get_height(), *path); } diff --git a/src/trigger/door.cpp b/src/trigger/door.cpp index 2c70c71f964..b1f4fa2f1c0 100644 --- a/src/trigger/door.cpp +++ b/src/trigger/door.cpp @@ -24,6 +24,7 @@ #include "supertux/game_session.hpp" #include "supertux/screen_manager.hpp" #include "supertux/sector.hpp" +#include "supertux/flip_level_transformer.hpp" #include "util/reader_mapping.hpp" Door::Door(const ReaderMapping& mapping) : @@ -33,7 +34,8 @@ Door::Door(const ReaderMapping& mapping) : target_spawnpoint(), script(), sprite(SpriteManager::current()->create("images/objects/door/door.sprite")), - stay_open_timer() + stay_open_timer(), + m_flip(NO_FLIP) { mapping.get("x", m_col.m_bbox.get_left()); mapping.get("y", m_col.m_bbox.get_top()); @@ -55,7 +57,8 @@ Door::Door(int x, int y, const std::string& sector, const std::string& spawnpoin target_spawnpoint(spawnpoint), script(), sprite(SpriteManager::current()->create("images/objects/door/door.sprite")), - stay_open_timer() + stay_open_timer(), + m_flip(NO_FLIP) { m_col.m_bbox.set_pos(Vector(static_cast(x), static_cast(y))); @@ -117,7 +120,7 @@ Door::update(float ) void Door::draw(DrawingContext& context) { - sprite->draw(context.color(), m_col.m_bbox.p1(), LAYER_BACKGROUNDTILES+1); + sprite->draw(context.color(), m_col.m_bbox.p1(), LAYER_BACKGROUNDTILES+1, m_flip); } void @@ -179,4 +182,11 @@ Door::collision(GameObject& other, const CollisionHit& hit_) return TriggerBase::collision(other, hit_); } +void +Door::on_flip(float height) +{ + MovingObject::on_flip(height); + FlipLevelTransformer::transform_flip(m_flip); +} + /* EOF */ diff --git a/src/trigger/door.hpp b/src/trigger/door.hpp index d9ea263a1b2..4bda5fbd2d4 100644 --- a/src/trigger/door.hpp +++ b/src/trigger/door.hpp @@ -19,6 +19,7 @@ #include "supertux/timer.hpp" #include "trigger/trigger_base.hpp" +#include "video/flip.hpp" class Player; class ReaderMapping; @@ -39,6 +40,7 @@ class Door final : public TriggerBase virtual void draw(DrawingContext& context) override; virtual void event(Player& player, EventType type) override; virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override; + virtual void on_flip(float height) override; private: enum DoorState { @@ -55,6 +57,7 @@ class Door final : public TriggerBase std::string script; SpritePtr sprite; /**< "door" sprite to render */ Timer stay_open_timer; /**< time until door will close again */ + Flip m_flip; private: Door(const Door&) = delete;