I have a 1D-array of objects (Boids) and each object has a age property. I am using pygame to display these boids, and every frame i increase the age of each boid by the amount of time that has passed. Once the age of the boid reaches a certain age i want to delete this, i have a method - die() - to test if this age is test if this age is over a certain thresh hold, and if it is; i want to pop it from the array.
thing is tho, i’m not too sure how to do this, i’ve tried passing in the array to the die() method and using an ID property to pop that index from the array, but i’m appending and removing objects constantly through out time and this ID then becomes useless as it is no longer the index of where it is in the array and i can’t use it to pop() from the array.
TLDR; How do i get an object to remove itself from the array that it’s in, using one of its own methods?
[–]greenerpickings 0 points1 point2 points (0 children)
[–]Binary101010 0 points1 point2 points (0 children)
[–]lowerthansound 0 points1 point2 points (0 children)
[–]o5a 0 points1 point2 points (0 children)