Skip to content

Commit

Permalink
Add an option to hide wind particles + set fancy as default (#2997)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruhmoent authored Jul 7, 2024
1 parent df670e4 commit 31dc707
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/object/wind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -75,18 +77,17 @@ 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");
result.add_bool(_("Blowing"), &blowing, "blowing", true);
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;
}
Expand All @@ -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<SpriteParticle>("images/particles/wind.sprite", (std::abs(speed.x) > std::abs(speed.y)) ? "default" : "flip", ppos, ANCHOR_MIDDLE, pspeed, Vector(0, 0), LAYER_BACKGROUNDTILES + 1);
Expand Down Expand Up @@ -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));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/object/wind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 31dc707

Please sign in to comment.