Skip to content

Commit effeb4a

Browse files
Fix ghost particles (#2952)
1 parent 18be4d3 commit effeb4a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/object/particlesystem.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,15 @@ ParticleSystem::draw(DrawingContext& context)
9999
pos.x = fmodf(particle->pos.x - scrollx, virtual_width);
100100
if ((pos.x + static_cast<float>(particle_width)) < 0) pos.x += virtual_width;
101101

102-
pos.y = fmodf(particle->pos.y - scrolly, virtual_height);
103-
if (pos.y < 0) pos.y += virtual_height;
102+
103+
const float particle_height = static_cast<float>(particle->texture->get_height());
104+
const float virtual_height_particle = virtual_height + particle_height;
105+
106+
pos.y = fmodf(particle->pos.y - scrolly, virtual_height_particle);
107+
if (pos.y + particle_height < 0)
108+
{
109+
pos.y += virtual_height_particle;
110+
}
104111

105112
if(!region.contains(pos + Sector::get().get_camera().get_translation()))
106113
continue;

0 commit comments

Comments
 (0)