Skip to content

Commit

Permalink
Fix issues introduced in #1922 (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkubax10 authored Dec 18, 2021
1 parent 5e50a35 commit 7cb51c7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/badguy/badguy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/object/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/object/decal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/object/flower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Flower::collision(GameObject& other, const CollisionHit& )
void
Flower::on_flip(float height)
{
MovingObject::on_flip(height);
FlipLevelTransformer::transform_flip(flip);
}

Expand Down
1 change: 1 addition & 0 deletions src/object/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
16 changes: 13 additions & 3 deletions src/trigger/door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Expand All @@ -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());
Expand All @@ -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<float>(x), static_cast<float>(y)));

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
3 changes: 3 additions & 0 deletions src/trigger/door.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "supertux/timer.hpp"
#include "trigger/trigger_base.hpp"
#include "video/flip.hpp"

class Player;
class ReaderMapping;
Expand All @@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit 7cb51c7

Please sign in to comment.