From 31dc707893b9beb3d9990e470ea3b80f917eafbb Mon Sep 17 00:00:00 2001 From: bruhmoent <69918580+bruhmoent@users.noreply.github.com> Date: Sun, 7 Jul 2024 14:31:31 +0200 Subject: [PATCH] Add an option to hide wind particles + set fancy as default (#2997) --- src/object/wind.cpp | 23 ++++++++++++----------- src/object/wind.hpp | 1 + 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/object/wind.cpp b/src/object/wind.cpp index b446c005243..f69c71be5fd 100644 --- a/src/object/wind.cpp +++ b/src/object/wind.cpp @@ -42,7 +42,8 @@ Wind::Wind(const ReaderMapping& reader) : affects_badguys(), affects_objects(), affects_player(), - fancy_wind() + fancy_wind(true), + particles_enabled(true) { float w,h; reader.get("x", m_col.m_bbox.get_left(), 0.0f); @@ -62,7 +63,8 @@ Wind::Wind(const ReaderMapping& reader) : reader.get("affects-objects", affects_objects, false); reader.get("affects-player", affects_player, true); - reader.get("fancy-wind", fancy_wind, false); + reader.get("fancy-wind", fancy_wind, true); + reader.get("particles-enabled", particles_enabled, true); set_group(COLGROUP_TOUCHABLE); } @@ -75,8 +77,6 @@ Wind::get_settings() ObjectSettings result = MovingObject::get_settings(); - //result.add_float("width", &new_size.x, "width", OPTION_HIDDEN); - //result.add_float("height", &new_size.y, "height", OPTION_HIDDEN); result.add_float(_("Speed X"), &speed.x, "speed-x"); result.add_float(_("Speed Y"), &speed.y, "speed-y"); result.add_float(_("Acceleration"), &acceleration, "acceleration"); @@ -84,9 +84,10 @@ Wind::get_settings() result.add_bool(_("Affects Badguys"), &affects_badguys, "affects-badguys", false); result.add_bool(_("Affects Objects"), &affects_objects, "affects-objects", false); result.add_bool(_("Affects Player"), &affects_player, "affects-player"); - result.add_bool(_("Fancy Particles"), &fancy_wind, "fancy-wind", false); + result.add_bool(_("Fancy Particles"), &fancy_wind, "fancy-wind", true); + result.add_bool(_("Particles Enabled"), &particles_enabled, "particles-enabled", true); - result.reorder({"blowing", "speed-x", "speed-y", "acceleration", "affects-badguys", "affects-objects", "affects-player", "fancy-wind", "region", "name", "x", "y"}); + result.reorder({ "blowing", "speed-x", "speed-y", "acceleration", "affects-badguys", "affects-objects", "affects-player", "fancy-wind", "particles-enabled", "region", "name", "x", "y" }); return result; } @@ -96,17 +97,17 @@ Wind::update(float dt_sec_) { dt_sec = dt_sec_; - if (!blowing) return; + if (!blowing || !particles_enabled) return; if (m_col.m_bbox.get_width() <= 16 || m_col.m_bbox.get_height() <= 16) return; - Vector ppos = Vector(graphicsRandom.randf(m_col.m_bbox.get_left()+8, m_col.m_bbox.get_right()-8), graphicsRandom.randf(m_col.m_bbox.get_top()+8, m_col.m_bbox.get_bottom()-8)); - Vector pspeed = Vector(graphicsRandom.randf(speed.x-20, speed.x+20), graphicsRandom.randf(speed.y-20, speed.y+20)); + Vector ppos = Vector(graphicsRandom.randf(m_col.m_bbox.get_left() + 8, m_col.m_bbox.get_right() - 8), graphicsRandom.randf(m_col.m_bbox.get_top() + 8, m_col.m_bbox.get_bottom() - 8)); + Vector pspeed = Vector(graphicsRandom.randf(speed.x - 20, speed.x + 20), graphicsRandom.randf(speed.y - 20, speed.y + 20)); // TODO: Rotate sprite rather than just use 2 different actions // Approx. 1 particle per tile if (graphicsRandom.randf(0.f, 100.f) < (m_col.m_bbox.get_width() / 32.f) * (m_col.m_bbox.get_height() / 32.f)) { - // emit a particle + // Emit a particle if (fancy_wind) { Sector::get().add("images/particles/wind.sprite", (std::abs(speed.x) > std::abs(speed.y)) ? "default" : "flip", ppos, ANCHOR_MIDDLE, pspeed, Vector(0, 0), LAYER_BACKGROUNDTILES + 1); @@ -148,7 +149,7 @@ Wind::collision(GameObject& other, const CollisionHit& ) } else { - //When on ground, get blown slightly differently, but the max speed is less than it would be otherwise seen as we take "friction" into account + // When on ground, get blown slightly differently, but the max speed is less than it would be otherwise seen as we take "friction" into account player->add_velocity((Vector(speed.x, 0) * 0.1f) * (acceleration+1), (Vector(speed.x, speed.y) * 0.5f)); } } diff --git a/src/object/wind.hpp b/src/object/wind.hpp index 2eb5562d710..787850a70cb 100644 --- a/src/object/wind.hpp +++ b/src/object/wind.hpp @@ -71,6 +71,7 @@ class Wind final : public MovingObject bool affects_objects; /**< whether the wind can affect objects */ bool affects_player; /**< whether the wind can affect the player: useful for cinematic wind */ bool fancy_wind; + bool particles_enabled; private: Wind(const Wind&) = delete;