Skip to content

Commit

Permalink
Merge branch 'SuperTux:master' into Autotilesets-for-Tileset-Variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Eauix authored Oct 23, 2024
2 parents 558a761 + c12c2bb commit fe90d6e
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 57 deletions.
10 changes: 2 additions & 8 deletions src/object/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static const float BOUNCY_BRICK_SPEED = 90;
static const float BUMP_ROTATION_ANGLE = 10;

Block::Block(const Vector& pos, const std::string& sprite_file) :
MovingSprite(pos, sprite_file),
MovingSprite(pos, sprite_file, LAYER_OBJECTS + 1),
m_bouncing(false),
m_breaking(false),
m_bounce_dir(0),
Expand All @@ -51,7 +51,7 @@ Block::Block(const Vector& pos, const std::string& sprite_file) :
}

Block::Block(const ReaderMapping& mapping, const std::string& sprite_file) :
MovingSprite(mapping, sprite_file),
MovingSprite(mapping, sprite_file, LAYER_OBJECTS + 1),
m_bouncing(false),
m_breaking(false),
m_bounce_dir(0),
Expand Down Expand Up @@ -149,12 +149,6 @@ Block::update(float dt_sec)
}
}

void
Block::draw(DrawingContext& context)
{
m_sprite->draw(context.color(), get_pos(), LAYER_OBJECTS+1, m_flip);
}

void
Block::start_bounce(GameObject* hitter)
{
Expand Down
3 changes: 0 additions & 3 deletions src/object/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ class Block : public MovingSprite

virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
virtual void update(float dt_sec) override;
virtual void draw(DrawingContext& context) override;

virtual void on_flip(float height) override;

virtual int get_layer() const override { return LAYER_OBJECTS + 1; }

void start_bounce(GameObject* hitter);

protected:
Expand Down
5 changes: 2 additions & 3 deletions src/object/candle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Candle::Candle(const ReaderMapping& mapping) :
mapping.get("flicker", flicker, true);
std::vector<float> vColor;
if (!mapping.get("color", vColor)) vColor = {1.0f, 1.0f, 1.0f};
mapping.get("layer", m_layer, 0);
mapping.get("layer", m_layer); // Backwards compatibility

// Change the light color if defined.
if (vColor.size() >= 3) {
Expand Down Expand Up @@ -75,9 +75,8 @@ Candle::get_settings()
result.add_bool(_("Burning"), &burning, "burning", true);
result.add_bool(_("Flicker"), &flicker, "flicker", true);
result.add_color(_("Color"), &lightcolor, "color", Color::WHITE);
result.add_int(_("Layer"), &m_layer, "layer", 0);

result.reorder({"burning", "flicker", "name", "sprite", "color", "layer", "x", "y"});
result.reorder({"burning", "flicker", "name", "sprite", "color", "z-pos", "x", "y"});

return result;
}
Expand Down
8 changes: 3 additions & 5 deletions src/object/conveyor_belt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "math/util.hpp"
#include "util/reader_mapping.hpp"

ConveyorBelt::ConveyorBelt(const ReaderMapping &reader) :
MovingSprite(reader, "images/objects/conveyor_belt/conveyor.sprite"),
ConveyorBelt::ConveyorBelt(const ReaderMapping& reader) :
MovingSprite(reader, "images/objects/conveyor_belt/conveyor.sprite", LAYER_TILES),
m_running(true),
m_dir(Direction::LEFT),
m_length(1),
Expand Down Expand Up @@ -110,9 +110,7 @@ ConveyorBelt::draw(DrawingContext &context)
for (int i = 0; i < m_length; i++)
{
m_sprite->set_frame(frame_index);
Vector pos = get_pos();
pos.x += static_cast<float>(i) * 32.0f;
m_sprite->draw(context.color(), pos, get_layer());
m_sprite->draw(context.color(), get_pos() + Vector(static_cast<float>(i) * 32.f, 0.f), m_layer);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/object/conveyor_belt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class ConveyorBelt final : public MovingSprite
virtual void update(float dt_sec) override;
virtual void draw(DrawingContext& context) override;

virtual int get_layer() const override { return LAYER_TILES; }

virtual void after_editor_set() override;

/** @name Scriptable Methods */
Expand Down
5 changes: 2 additions & 3 deletions src/object/lit_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "util/reader_mapping.hpp"

LitObject::LitObject(const ReaderMapping& reader) :
MovingSprite(reader, "images/objects/lightflower/lightflower1.sprite"),
MovingSprite(reader, "images/objects/lightflower/lightflower1.sprite", LAYER_TILES),
m_light_offset(-6.f, -17.f),
m_light_sprite_name("images/objects/lightflower/light/glow_light.sprite"),
m_sprite_action("default"),
Expand All @@ -36,7 +36,7 @@ LitObject::LitObject(const ReaderMapping& reader) :
reader.get("light-offset-y", m_light_offset.y);

reader.get("light-sprite", m_light_sprite_name);
reader.get("layer", m_layer, 0);
reader.get("layer", m_layer); // Backwards compatibility

reader.get("action", m_sprite_action);
reader.get("light-action", m_light_sprite_action);
Expand Down Expand Up @@ -68,7 +68,6 @@ LitObject::get_settings()
ObjectSettings result = MovingSprite::get_settings();

result.add_sprite(_("Light sprite"), &m_light_sprite_name, "light-sprite", "images/objects/lightflower/light/glow_light.sprite");
result.add_int(_("Layer"), &m_layer, "layer", 0);

result.add_text(_("Sprite starting action"), &m_sprite_action, "action", "default");
result.add_text(_("Light sprite starting action"), &m_light_sprite_action, "light-action", "default");
Expand Down
2 changes: 0 additions & 2 deletions src/object/lit_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class LitObject final : public MovingSprite
virtual ObjectSettings get_settings() override;
virtual void after_editor_set() override;

virtual int get_layer() const override { return m_layer; }

virtual void on_flip(float height) override;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/object/moving_sprite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MovingSprite : public MovingObject
virtual void after_editor_set() override;
virtual void on_type_change(int old_type) override;

virtual int get_layer() const override { return m_layer; }
int get_layer() const override { return m_layer; }

bool has_found_sprite() const { return m_sprite_found; }
const std::string& get_sprite_name() const { return m_sprite_name; }
Expand Down
7 changes: 0 additions & 7 deletions src/object/particlesystem_interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "object/particlesystem_interactive.hpp"

#include "collision/collision.hpp"
#include "editor/editor.hpp"
#include "math/aatriangle.hpp"
#include "object/tilemap.hpp"
#include "supertux/globals.hpp"
Expand All @@ -36,19 +35,13 @@ ParticleSystem_Interactive::ParticleSystem_Interactive() :
{
virtual_width = static_cast<float>(SCREEN_WIDTH);
virtual_height = static_cast<float>(SCREEN_HEIGHT);
if (!Editor::is_active()) {
z_pos = 0;
}
}

ParticleSystem_Interactive::ParticleSystem_Interactive(const ReaderMapping& mapping) :
ParticleSystem(mapping)
{
virtual_width = static_cast<float>(SCREEN_WIDTH);
virtual_height = static_cast<float>(SCREEN_HEIGHT);
if (!Editor::is_active()) {
z_pos = 0;
}
}

ParticleSystem_Interactive::~ParticleSystem_Interactive()
Expand Down
2 changes: 1 addition & 1 deletion src/object/rain_particle_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void RainParticleSystem::draw(DrawingContext& context)
context.set_translation(Vector(0, 0));
context.color().draw_filled_rect(context.get_rect(),
Color(0.3f, 0.38f, 0.4f, opacity),
199); // TODO: Change the hardcoded layer value with the rain's layer
z_pos);
context.pop_transform();
}

Expand Down
7 changes: 4 additions & 3 deletions src/object/spotlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"
#include "util/reader.hpp"
#include "util/reader_mapping.hpp"

Spotlight::Direction
Expand Down Expand Up @@ -87,7 +88,7 @@ Spotlight::Spotlight(const ReaderMapping& mapping) :
if (mapping.get("color", vColor))
m_color = Color(vColor);

mapping.get("layer", m_layer, 0);
m_layer = reader_get_layer(mapping, LAYER_TILES);
mapping.get("enabled", m_enabled, true);
}

Expand All @@ -108,9 +109,9 @@ Spotlight::get_settings()
{_("Clockwise"), _("Counter-clockwise"), _("Stopped")},
{"clockwise", "counter-clockwise", "stopped"},
static_cast<int>(Direction::CLOCKWISE), "r-direction");
result.add_int(_("Layer"), &m_layer, "layer", 0);
result.add_int(_("Z-pos"), &m_layer, "z-pos", 0);

result.reorder({"angle", "color", "layer", "x", "y"});
result.reorder({"angle", "color", "z-pos", "x", "y"});

return result;
}
Expand Down
7 changes: 3 additions & 4 deletions src/object/torch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
#include "util/reader_mapping.hpp"

Torch::Torch(const ReaderMapping& reader) :
MovingSprite(reader, "images/objects/torch/torch1.sprite"),
MovingSprite(reader, "images/objects/torch/torch1.sprite", LAYER_TILES),
m_light_color(1.f, 1.f, 1.f),
m_flame(SpriteManager::current()->create("images/objects/torch/flame.sprite")),
m_flame_glow(SpriteManager::current()->create("images/objects/torch/flame_glow.sprite")),
m_flame_light(SpriteManager::current()->create("images/objects/torch/flame_light.sprite")),
m_burning(true)
{
reader.get("burning", m_burning, true);
reader.get("layer", m_layer, 0);
reader.get("layer", m_layer); // Backwards compatibility

std::vector<float> vColor;
if (!reader.get("color", vColor)) vColor = { 1.f, 1.f, 1.f };
Expand Down Expand Up @@ -94,10 +94,9 @@ Torch::get_settings()
ObjectSettings result = MovingSprite::get_settings();

result.add_bool(_("Burning"), &m_burning, "burning", true);
result.add_int(_("Layer"), &m_layer, "layer", 0);
result.add_color(_("Color"), &m_light_color, "color", Color::WHITE);

result.reorder({"burning", "sprite", "layer", "color", "x", "y"});
result.reorder({"burning", "sprite", "z-pos", "color", "x", "y"});

return result;
}
Expand Down
2 changes: 0 additions & 2 deletions src/object/torch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class Torch final : public MovingSprite
virtual ObjectSettings get_settings() override;
virtual void after_editor_set() override;

virtual int get_layer() const override { return m_layer; }

virtual void on_flip(float height) override;

/**
Expand Down
6 changes: 2 additions & 4 deletions src/object/weak_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "util/writer.hpp"

WeakBlock::WeakBlock(const ReaderMapping& mapping) :
MovingSprite(mapping, "images/objects/weak_block/meltbox.sprite", LAYER_TILES, COLGROUP_STATIC),
MovingSprite(mapping, "images/objects/weak_block/meltbox.sprite", LAYER_OBJECTS + 10, COLGROUP_STATIC),
state(STATE_NORMAL),
lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
{
Expand Down Expand Up @@ -213,9 +213,7 @@ WeakBlock::update(float )
void
WeakBlock::draw(DrawingContext& context)
{
//Draw the Sprite just in front of other objects
m_sprite->draw(context.color(), get_pos(), LAYER_OBJECTS + 10, m_flip);

MovingSprite::draw(context);
if (m_type == HAY && (state != STATE_NORMAL))
{
lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0);
Expand Down
5 changes: 2 additions & 3 deletions src/trigger/door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static const float CENTER_EPSILON = 5.0f;
static const float WALK_SPEED = 100.0f;

Door::Door(const ReaderMapping& mapping) :
SpritedTrigger(mapping, "images/objects/door/door.sprite"),
SpritedTrigger(mapping, "images/objects/door/door.sprite", LAYER_BACKGROUNDTILES + 1),
m_state(CLOSED),
m_target_sector(),
m_target_spawnpoint(),
Expand Down Expand Up @@ -163,8 +163,7 @@ Door::update(float )
void
Door::draw(DrawingContext& context)
{
m_sprite->draw(context.color(), m_col.m_bbox.p1(), LAYER_BACKGROUNDTILES+1, m_flip);

MovingSprite::draw(context);
if (m_state == DoorState::LOCKED || m_state == DoorState::UNLOCKING)
{
Vector shake_delta = Vector(static_cast<float>(graphicsRandom.rand(-8, 8)), static_cast<float>(graphicsRandom.rand(-8, 8)));
Expand Down
8 changes: 4 additions & 4 deletions src/trigger/trigger_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ Trigger::Trigger(const ReaderMapping& reader) :
}


SpritedTrigger::SpritedTrigger(const ReaderMapping& reader, const std::string& sprite_name) :
MovingSprite(reader, sprite_name, LAYER_TILES + 1, COLGROUP_TOUCHABLE)
SpritedTrigger::SpritedTrigger(const ReaderMapping& reader, const std::string& sprite_name, int layer) :
MovingSprite(reader, sprite_name, layer, COLGROUP_TOUCHABLE)
{
}


StickyTrigger::StickyTrigger(const ReaderMapping& reader, const std::string& sprite_name) :
StickyObject(reader, sprite_name, LAYER_TILES + 1, COLGROUP_TOUCHABLE)
StickyTrigger::StickyTrigger(const ReaderMapping& reader, const std::string& sprite_name, int layer) :
StickyObject(reader, sprite_name, layer, COLGROUP_TOUCHABLE)
{
}

Expand Down
10 changes: 8 additions & 2 deletions src/trigger/trigger_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ class SpritedTrigger : public MovingSprite,
public TriggerBase
{
public:
SpritedTrigger(const ReaderMapping& reader, const std::string& sprite_name);
SpritedTrigger(const ReaderMapping& reader,
const std::string& sprite_name,
int layer = LAYER_TILES + 1);

virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(TriggerBase)).add(typeid(SpritedTrigger)); }

virtual void update(float) override
Expand All @@ -113,7 +116,10 @@ class StickyTrigger : public StickyObject,
public TriggerBase
{
public:
StickyTrigger(const ReaderMapping& reader, const std::string& sprite_name);
StickyTrigger(const ReaderMapping& reader,
const std::string& sprite_name,
int layer = LAYER_TILES + 1);

virtual GameObjectClasses get_class_types() const override { return StickyObject::get_class_types().add(typeid(TriggerBase)).add(typeid(StickyTrigger)); }

virtual void update(float dt_sec) override
Expand Down

0 comments on commit fe90d6e

Please sign in to comment.