Skip to content

Commit

Permalink
Fixed removing particles too early
Browse files Browse the repository at this point in the history
  • Loading branch information
ccetl committed Feb 25, 2024
1 parent aaf46bb commit 14c4e1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ plugins {
}

group = 'ccetl'
version = '1.0.3'
version = '1.0.4'
14 changes: 10 additions & 4 deletions src/main/java/de/ccetl/jparticles/systems/ParticleSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,21 @@ private void updateXY(double mouseX, double mouseY) {
if (movingOutHorizontal && options.getCollisionEdge() == Obstacle.BOUNCE) {
dot.setVx(-dot.getVx());
dot.setVelocityChanged(true);
} else if (movingOutHorizontal && (x + r < 0 || x - r > width) && options.getCollisionEdge() == Obstacle.IGNORE) {
toRemove.add(dot);
} else {
Trail trail = dot.getTrail().peek();
if (movingOutHorizontal && (x + r < 0 || x - r > width) && dot.getTrail().isEmpty() && options.getCollisionEdge() == Obstacle.IGNORE && (trail == null || trail.getX() + r < 0 || trail.getX() - r > width)) {
toRemove.add(dot);
}
}

if (movingOutVertical && options.getCollisionEdge() == Obstacle.BOUNCE) {
dot.setVy(-dot.getVy());
dot.setVelocityChanged(true);
} else if (movingOutVertical && (y + r < 0 || y - r > height) && options.getCollisionEdge() == Obstacle.IGNORE) {
toRemove.add(dot);
} else {
Trail trail = dot.getTrail().peek();
if (movingOutVertical && (y + r < 0 || y - r > height) && options.getCollisionEdge() == Obstacle.IGNORE && (trail == null || trail.getY() + r < 0 || trail.getY() - r > height)) {
toRemove.add(dot);
}
}
}

Expand Down

0 comments on commit 14c4e1b

Please sign in to comment.