I'm storing particles in an atom and I would like to remove them from the collection atom once a condition is met, here is my update-particle function:
(defn update-particle
[{:keys [position velocity age] :as particle}]
(let [new-position-x (+ (:x position) (:x velocity))
new-position-y (+ (:y position) (:y velocity))
new-age (if (> age 0) (dec age) 0)
new-is-dead (if (= age 0) true false)]
(println new-is-dead)
(assoc particle
:position {:x new-position-x
:y new-position-y}
:age new-age
:is-dead new-is-dead)))
So the particle slowly die on each frame by decrementing the "age" local variable and when the age reach 0 the "is-dead" property of the particle is updated to "true" and is at that moment when I need to remove the particle from the atom.
Hope that makes sense, any help will be much appreciated